<?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>John Roach &#187; ip home automation project</title>
	<atom:link href="http://johnroach.info/category/eoyproject/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnroach.info</link>
	<description>Coding for life</description>
	<lastBuildDate>Wed, 18 Jan 2012 19:30:55 +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>Setting up a CVS server for the BlackBox project</title>
		<link>http://johnroach.info/2009/12/13/setting-up-a-cvs-server-for-the-blackbox-project/</link>
		<comments>http://johnroach.info/2009/12/13/setting-up-a-cvs-server-for-the-blackbox-project/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 09:05:28 +0000</pubDate>
		<dc:creator>John Roach</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ip home automation project]]></category>
		<category><![CDATA[cvs]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[fedora 11]]></category>
		<category><![CDATA[fedora 12]]></category>
		<category><![CDATA[john roach]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://johnroach.info/?p=172</guid>
		<description><![CDATA[Following the previous posts in this category you will notice that I was using Sourceforge.net as the code hosting. We had to change that because we really didn&#8217;t want to share every bit of code. ( A big sorry to &#8230; <a href="http://johnroach.info/2009/12/13/setting-up-a-cvs-server-for-the-blackbox-project/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Following the previous posts in this category you will notice that I was using Sourceforge.net as the code hosting. We had to change that because we really didn&#8217;t want to share every bit of code. ( A big sorry to open source developers. I am truly a sell out. ) So had to set up CVS server. Never done that before. Should probably add it to my CV. Anyways to business.</p>
<p><strong>How to set up a CVS server using SSH :</strong></p>
<p><span id="more-172"></span><strong>Step 1 : </strong>Install CVS to Fedora. My Fedora distro came with CVS since I chose developer properties during installation. However you may not have it to install simply say;</p>
<p><code>sudo yum install cvs</code></p>
<p><strong>Step 2 : </strong>Create a cvs user and group! Just follow the code below;<br />
<code>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">useradd cvs</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">groupadd cvs</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mkdir /home/cvs</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 129px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">cvs -d /home/cvs init</div>
<p>useradd cvs</p>
<p>groupadd cvs</p>
<p>mkdir /home/cvs<br />
</code><br />
<strong>Step 3 : </strong>Set permissions and add /home/cvs directory to cvs by using the following;</p>
<p><code>cvs -d /home/cvs init</p>
<p>chown -R cvs:cvs /home/cvs</p>
<p>chmod -R 770 /home/cvs</p>
<p>chmod 700   /home/cvs/CVSROOT</code></p>
<p><strong>Step 4 : </strong>Now you have to add your project to the CVS server. I assume you have a ~/project<strong> </strong>directory on the server. Just follow the following commands;</p>
<p><code>cd ~/project</p>
<p>cvs -d /home/cvs import -m "Initial Import" project myname release</p>
<p>cvs -d /home/cvs checkout project</code></p>
<p><strong>Step 5 :</strong> Add an account to the CVS server (preferably with the same username and password of the user acount you have created for the CVS server that will connect through SSH.) Use the following by replacing &lt;username&gt; and &lt;password&gt;</p>
<p><code>echo "&lt;username&gt;:&lt;password&gt;" &gt;&gt; /home/cvs/CVSROOT/passwd</code></p>
<p><strong>Step 6 :</strong> Make sure you have created a user to connect through SSH give him CVS group permission.</p>
<p>And that is that. It should work. Though you may need to do some changes in <strong>Step 3.</strong> To connect you can simply use the following code or just use Eclipse&#8217;s IDE ( that is what we are using. )</p>
<p><code>export CVS_RSH=ssh</p>
<p>cvs -d :ext:username@repository.host.name:/home/cvs login</p>
<p>cvs -d :ext:username@repository.host.name:/home/cvs co moduleName</code></p>
<p>I hope it will be helpful. Peace! </p>
]]></content:encoded>
			<wfw:commentRss>http://johnroach.info/2009/12/13/setting-up-a-cvs-server-for-the-blackbox-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Ångström Linux on BeagleBoard</title>
		<link>http://johnroach.info/2009/11/27/installing-angstrom-linux-on-beagleboard/</link>
		<comments>http://johnroach.info/2009/11/27/installing-angstrom-linux-on-beagleboard/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 07:57:21 +0000</pubDate>
		<dc:creator>John Roach</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[ip home automation project]]></category>
		<category><![CDATA[angstrom]]></category>
		<category><![CDATA[beagleboard]]></category>
		<category><![CDATA[embedded device]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[paramiko]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sd card]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://johnroach.info/?p=164</guid>
		<description><![CDATA[We have been able to install Ångström Linux to our beagle board. Ran into couple problems. The first one was we trusted BeagleBoard Beginners wiki just too much!! You see we learned that we should NOT set any environment variables while using &#8230; <a href="http://johnroach.info/2009/11/27/installing-angstrom-linux-on-beagleboard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We have been able to install Ångström Linux to our beagle board. Ran into couple problems. The first one was we trusted <a title="BeagleBoardBeginners Wiki" href="http://elinux.org/BeagleBoardBeginners" target="_blank">BeagleBoard Beginners</a> wiki just too much!!</p>
<p>You see we learned that we should NOT set any environment variables while using demo u-boot image which was downloaded from <a title="Angstrom demo images" href="http://www.angstrom-distribution.org/demo/beagleboard/" target="_blank">here</a>. In fact what we did is we created our own Ångström image (from Ångström site) and simply installed that to our Linux partition of our SDHC card. And it worked beautifully. Though I must say first boot is a drag, very very slow.</p>
<p><span id="more-164"></span></p>
<p>Ran to some problems again. It seems BeagleBoard only works with DVI-D LCD&#8217;s and we had a HDMI to VGA instead of a HDMI to DVI-D cable.We ended up connecting to it from SSH and installing our programs like that. We really don&#8217;t need an LCD any time soon. And to connect to it from SSH we had to learn it&#8217;s IP from terminal. So no problems there. And we were very happy with the outcome.</p>
<div class="flashalbum">
<div class="flagallery_swfobject" id="sid_742396521_div"><style type="text/css">
.flashalbum { clear: both; }
.flag_alternate { display: none; }
.flag_alternate .flagcatlinks { padding: 7px 3px; margin:0 0 3px; background-color: #292929; }
.flag_alternate .flagcatlinks a.flagcat { padding: 4px 10px; margin: 0; border: none; border-left: 1px dotted #ffffff; font: 14px Tahoma; text-decoration: none; background: none; color: #ffffff; background-color: #292929; }
.flag_alternate .flagcatlinks a.flagcat:hover { text-decoration: none; background: none; border: none; border-left: 1px dotted #ffffff; }
.flag_alternate .flagcatlinks a.active, .flag_alternate .flagcatlinks a.flagcat:hover { color: #ffffff; background-color: #737373; outline: none; }
.flag_alternate .flagcatlinks a.flagcat:first-child { border: none; }
.flag_alternate .flagcategory { display: none; font-size: 0; line-height: 0; }
.flag_alternate { background-color: transparent; margin: 7px 0; }
.flag_alternate .flagcategory { width: 100%; height: auto; position: relative; text-align: center; padding-bottom: 4px; }
.flag_alternate .flagcategory a.flag_pic_alt { display: inline-block; margin: 1px 0 0 1px; padding: 0; height: 100px; width: 115px; line-height: 96px; position:relative; z-index: 2; text-align: center; z-index:99; cursor:pointer; background-color: #ffffff; border: 2px solid #ffffff; text-decoration: none; background-image: url(http://johnroach.info/wp-content/plugins/flash-album-gallery/admin/images/loadingAnimation.gif); background-repeat: no-repeat; background-position: 50% 50%; font-size: 8px; color: #ffffff; }
.flag_alternate .flagcategory a.flag_pic_alt > .flag_pic_desc { display: none; padding: 4px; line-height: 140%; font-size: 12px; }
.flag_alternate .flagcategory a.flag_pic_alt > .flag_pic_desc * { display: none; line-height: 140%; font-size: 12px !important; }
.flag_alternate .flagcategory a.flag_pic_alt:hover { background-color: #ffffff; border: 2px solid #4a4a4a; color: #4a4a4a; text-decoration: none; z-index: 3; }
.flag_alternate .flagcategory a.flag_pic_alt.current, .flag_alternate .flagcategory a.flag_pic_alt.last { border-color: #4a4a4a; }
.flag_alternate .flagcategory a.flag_pic_alt > img { vertical-align: middle; display:inline-block; position: static; margin: 0 auto; padding: 0; border: none; height: 100px !important; width: 115px !important; max-width: 115px; min-width: 115px; }

#fancybox-title-over .title { color: #ff9900; }
#fancybox-title-over .descr { color: #cfcfcf; }
.flag_alternate .flagcatlinks { background-color: #292929; }
.flag_alternate .flagcatlinks a.flagcat { border-color: #ffffff; color: #ffffff; background-color: #292929; }
.flag_alternate .flagcatlinks a.flagcat:hover { border-color: #ffffff; }
.flag_alternate .flagcatlinks a.active, .flag_alternate .flagcatlinks a.flagcat:hover { color: #ffffff; background-color: #737373; }
	.flag_alternate .flagcategory a.flag_pic_alt { background-color: #ffffff; border: 2px solid #ffffff; color: #ffffff; }
.flag_alternate .flagcategory a.flag_pic_alt:hover { background-color: #ffffff; border: 2px solid #4a4a4a; color: #4a4a4a; }
.flag_alternate .flagcategory a.flag_pic_alt.current, .flag_alternate .flagcategory a.flag_pic_alt.last { border-color: #4a4a4a; }
</style>
<script type="text/javascript">var ExtendVar='http://johnroach.info/wp-content/plugins/flash-album-gallery/';</script>
<div id="sid_742396521_jq" class="flag_alternate">
		<div class="flagcatlinks"></div>
			<div class="flagCatMeta">
			<h4>angstrombeagleboard</h4>
			<p></p>
		</div>
		<div class="flagcategory" id="gid_4_sid_742396521">
			<a class="i0 flag_pic_alt" href="http://johnroach.info/wp-content/flagallery/angstrombeagleboard/angstrom.png" id="flag_pic_5" rel="gid_4_sid_742396521" title="">[img src=http://johnroach.info/wp-content/flagallery/angstrombeagleboard/thumbs/thumbs_angstrom.png]<span class="flag_pic_desc" id="flag_desc_5"><strong></strong><br /><span></span></span></a><a class="i1 flag_pic_alt" href="http://johnroach.info/wp-content/flagallery/angstrombeagleboard/image000.jpg" id="flag_pic_6" rel="gid_4_sid_742396521" title="">[img src=http://johnroach.info/wp-content/flagallery/angstrombeagleboard/thumbs/thumbs_image000.jpg]<span class="flag_pic_desc" id="flag_desc_6"><strong></strong><br /><span></span></span></a><a class="i2 flag_pic_alt" href="http://johnroach.info/wp-content/flagallery/angstrombeagleboard/image001.jpg" id="flag_pic_8" rel="gid_4_sid_742396521" title="">[img src=http://johnroach.info/wp-content/flagallery/angstrombeagleboard/thumbs/thumbs_image001.jpg]<span class="flag_pic_desc" id="flag_desc_8"><strong></strong><br /><span></span></span></a>		</div>
	</div>

</div></div>
<script type="text/javascript" defer="defer">
flag_alt['sid_742396521'] = jQuery("div#sid_742396521_jq").clone().wrap(document.createElement('div')).parent().html();
var sid_742396521_div = {
	params : {
		wmode : "opaque",
		allowfullscreen : "true",
		allowScriptAccess : "always",
		saling : "lt",
		scale : "noScale",
		menu : "false",
		bgcolor : "##262626"},
	flashvars : {
		path : "http://johnroach.info/wp-content/plugins/flagallery-skins/default/",
		gID : "4",
		galName : "Gallery",
		skinID : "sid_742396521",
		postID : "164",
		postTitle : "Installing+%C3%85ngstr%C3%B6m+Linux+on+BeagleBoard+"},
	attr : {
		styleclass : "flashalbum",
		id : "sid_742396521"},
	start : function() {
		swfobject.embedSWF("http://johnroach.info/wp-content/plugins/flagallery-skins/default/gallery.swf", "sid_742396521_div", "100%", "500", "10.1.52", "http://johnroach.info/wp-content/plugins/flash-album-gallery/skins/expressInstall.swf", this.flashvars, this.params , this.attr );
swfobject.createCSS("#sid_742396521","outline:none");
	}
}
sid_742396521_div.start();
</script>
<p>Installing python libraries; as installing python libraries go this one was a little tricky. You see it seems that Ångström doesn&#8217;t update its python libs that frequently. So calling the package by</p>
<p><code>opkg intall python-pycrypto</code></p>
<p>Didn&#8217;t quite work since installed itself to python2.5 directory. Had to install pycrypto manually. I hated every moment of it. I  than uploaded my own program and I was very happy with the outcome. The program worked perfectly.</p>
<p>Stay tuned for more updates on The Black Box project! Remember you can find it at<a href="http://sourceforge.net/projects/theblackbox/">http://sourceforge.net/projects/theblackbox/</a> .</p>
<p>Live coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://johnroach.info/2009/11/27/installing-angstrom-linux-on-beagleboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The BeagleBoard Has Arrived!!</title>
		<link>http://johnroach.info/2009/11/12/the-beagleboard-has-arrived/</link>
		<comments>http://johnroach.info/2009/11/12/the-beagleboard-has-arrived/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 09:16:08 +0000</pubDate>
		<dc:creator>John Roach</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[ip home automation project]]></category>
		<category><![CDATA[beagleboard]]></category>
		<category><![CDATA[cvs]]></category>
		<category><![CDATA[embedded device]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sd card]]></category>

		<guid isPermaLink="false">http://johnroach.info/?p=116</guid>
		<description><![CDATA[The long awaited Beagle board has arrived. Even tough the team&#8217;s enthusiasm was up the roof we were not able to try it out. More on this later. I would also like to inform all people who is following this &#8230; <a href="http://johnroach.info/2009/11/12/the-beagleboard-has-arrived/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The long awaited Beagle board has arrived.<br />
<center><div class="flashalbum">
<div class="flagallery_swfobject" id="sid_1340133983_div"><style type="text/css">
.flashalbum { clear: both; }
.flag_alternate { display: none; }
.flag_alternate .flagcatlinks { padding: 7px 3px; margin:0 0 3px; background-color: #292929; }
.flag_alternate .flagcatlinks a.flagcat { padding: 4px 10px; margin: 0; border: none; border-left: 1px dotted #ffffff; font: 14px Tahoma; text-decoration: none; background: none; color: #ffffff; background-color: #292929; }
.flag_alternate .flagcatlinks a.flagcat:hover { text-decoration: none; background: none; border: none; border-left: 1px dotted #ffffff; }
.flag_alternate .flagcatlinks a.active, .flag_alternate .flagcatlinks a.flagcat:hover { color: #ffffff; background-color: #737373; outline: none; }
.flag_alternate .flagcatlinks a.flagcat:first-child { border: none; }
.flag_alternate .flagcategory { display: none; font-size: 0; line-height: 0; }
.flag_alternate { background-color: transparent; margin: 7px 0; }
.flag_alternate .flagcategory { width: 100%; height: auto; position: relative; text-align: center; padding-bottom: 4px; }
.flag_alternate .flagcategory a.flag_pic_alt { display: inline-block; margin: 1px 0 0 1px; padding: 0; height: 100px; width: 115px; line-height: 96px; position:relative; z-index: 2; text-align: center; z-index:99; cursor:pointer; background-color: #ffffff; border: 2px solid #ffffff; text-decoration: none; background-image: url(http://johnroach.info/wp-content/plugins/flash-album-gallery/admin/images/loadingAnimation.gif); background-repeat: no-repeat; background-position: 50% 50%; font-size: 8px; color: #ffffff; }
.flag_alternate .flagcategory a.flag_pic_alt > .flag_pic_desc { display: none; padding: 4px; line-height: 140%; font-size: 12px; }
.flag_alternate .flagcategory a.flag_pic_alt > .flag_pic_desc * { display: none; line-height: 140%; font-size: 12px !important; }
.flag_alternate .flagcategory a.flag_pic_alt:hover { background-color: #ffffff; border: 2px solid #4a4a4a; color: #4a4a4a; text-decoration: none; z-index: 3; }
.flag_alternate .flagcategory a.flag_pic_alt.current, .flag_alternate .flagcategory a.flag_pic_alt.last { border-color: #4a4a4a; }
.flag_alternate .flagcategory a.flag_pic_alt > img { vertical-align: middle; display:inline-block; position: static; margin: 0 auto; padding: 0; border: none; height: 100px !important; width: 115px !important; max-width: 115px; min-width: 115px; }

#fancybox-title-over .title { color: #ff9900; }
#fancybox-title-over .descr { color: #cfcfcf; }
.flag_alternate .flagcatlinks { background-color: #292929; }
.flag_alternate .flagcatlinks a.flagcat { border-color: #ffffff; color: #ffffff; background-color: #292929; }
.flag_alternate .flagcatlinks a.flagcat:hover { border-color: #ffffff; }
.flag_alternate .flagcatlinks a.active, .flag_alternate .flagcatlinks a.flagcat:hover { color: #ffffff; background-color: #737373; }
	.flag_alternate .flagcategory a.flag_pic_alt { background-color: #ffffff; border: 2px solid #ffffff; color: #ffffff; }
.flag_alternate .flagcategory a.flag_pic_alt:hover { background-color: #ffffff; border: 2px solid #4a4a4a; color: #4a4a4a; }
.flag_alternate .flagcategory a.flag_pic_alt.current, .flag_alternate .flagcategory a.flag_pic_alt.last { border-color: #4a4a4a; }
</style>
<script type="text/javascript">var ExtendVar='http://johnroach.info/wp-content/plugins/flash-album-gallery/';</script>
<div id="sid_1340133983_jq" class="flag_alternate">
		<div class="flagcatlinks"></div>
			<div class="flagCatMeta">
			<h4>BeagleBoardArrival</h4>
			<p></p>
		</div>
		<div class="flagcategory" id="gid_1_sid_1340133983">
			<a class="i0 flag_pic_alt" href="http://johnroach.info/wp-content/flagallery/beagleboardarrival/image023.jpg" id="flag_pic_1" rel="gid_1_sid_1340133983" title="">[img src=http://johnroach.info/wp-content/flagallery/beagleboardarrival/thumbs/thumbs_image023.jpg]<span class="flag_pic_desc" id="flag_desc_1"><strong></strong><br /><span></span></span></a><a class="i1 flag_pic_alt" href="http://johnroach.info/wp-content/flagallery/beagleboardarrival/image025.jpg" id="flag_pic_2" rel="gid_1_sid_1340133983" title="">[img src=http://johnroach.info/wp-content/flagallery/beagleboardarrival/thumbs/thumbs_image025.jpg]<span class="flag_pic_desc" id="flag_desc_2"><strong></strong><br /><span></span></span></a>		</div>
	</div>

</div></div>
<script type="text/javascript" defer="defer">
flag_alt['sid_1340133983'] = jQuery("div#sid_1340133983_jq").clone().wrap(document.createElement('div')).parent().html();
var sid_1340133983_div = {
	params : {
		wmode : "opaque",
		allowfullscreen : "true",
		allowScriptAccess : "always",
		saling : "lt",
		scale : "noScale",
		menu : "false",
		bgcolor : "##262626"},
	flashvars : {
		path : "http://johnroach.info/wp-content/plugins/flagallery-skins/default/",
		gID : "1",
		galName : "Gallery",
		skinID : "sid_1340133983",
		postID : "116",
		postTitle : "The+BeagleBoard+Has+Arrived%21%21+"},
	attr : {
		styleclass : "flashalbum",
		id : "sid_1340133983"},
	start : function() {
		swfobject.embedSWF("http://johnroach.info/wp-content/plugins/flagallery-skins/default/gallery.swf", "sid_1340133983_div", "100%", "500", "10.1.52", "http://johnroach.info/wp-content/plugins/flash-album-gallery/skins/expressInstall.swf", this.flashvars, this.params , this.attr );
swfobject.createCSS("#sid_1340133983","outline:none");
	}
}
sid_1340133983_div.start();
</script></center><br />
Even tough the team&#8217;s enthusiasm was up the roof we were not able to try it out. More on this later. I would also like to inform all people who is following this blog religiously that our project is now hosted on SourceForge.net at <a title="SourceForge.net link" href="http://sourceforge.net/projects/theblackbox/" target="_blank">http://sourceforge.net/projects/theblackbox/</a> . And I have also set up a CVS so those who want to follow the code will be able to follow it from the net.</p>
<p>The CVS code is as follows</p>
<p><code>cvs -d:pserver:anonymous@theblackbox.cvs.sourceforge.net:/cvsroot/theblackbox login</code></p>
<p><code> </code></p>
<p><code>cvs -z3 -d:pserver:anonymous@theblackbox.cvs.sourceforge.net:/cvsroot/theblackbox co -P modulename</code></p>
<p>I am sorry to say due to some weird problem you can not view the CVS modules from Sourceforge. You will need to use some kind of client. I am currently using Eclipse as my development IDE hence all my CVS materials comes from that. I have heard that TortoiseCVS is quite neat in its own way (for Windows) but I&#8217;d rather use Eclipse your choice.</p>
<p><span id="more-116"></span>Please feel free to be a part of the project. Warning us of any bugs will be rewarded with a Cookie.</p>
<p>Now back to the BeagleBoard was indeed a great buy. Small and fast. Though the peripherals cost us quite much. We installed Angstrom Linux  distribution. Which could be found at <a title="Angstrom Distro Site" href="http://www.angstrom-distribution.org/" target="_blank">http://www.angstrom-distribution.org/</a> . Being new in using the BeagleBoard we decided to use some of the sources at hand. We started with the site <a title="BeagleBoard Beginners Site Link" href="http://elinux.org/BeagleBoardBeginners" target="_blank">http://elinux.org/BeagleBoardBeginners</a> . We ran into some problems.</p>
<p>Our first problem was that we did not have a AT-Everex cable to connect to the board. So we had to jump to Step 5 of the steps presented in the web-site.  Which is basicly Linux Boot Formatting the SDHC disc we bought for the board. I beg you please not to follow the steps at elinux.org instead follow <a title="SD card formatting link" href="http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat" target="_blank">http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat</a> . It is much more clear and you don&#8217;t get side stepped. Once we used the steps in formatting the SD disk in code.google.com we noticed we needed cable so we can tell the board where to boot from. So until we get that cable (or make one for our selves?) the project is at a halt. Just follow this blog for any more updates on the board and follow the Sourceforge.net &#8216;s for the changes on our code.</p>
<p>Peace!</p>
]]></content:encoded>
			<wfw:commentRss>http://johnroach.info/2009/11/12/the-beagleboard-has-arrived/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Workflow of the BlackBox System and Connecting in Two Steps (Python+SSH)</title>
		<link>http://johnroach.info/2009/10/31/workflow-of-the-blackbox-system-and-connecting-in-two-steps-pythonssh/</link>
		<comments>http://johnroach.info/2009/10/31/workflow-of-the-blackbox-system-and-connecting-in-two-steps-pythonssh/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 19:00:12 +0000</pubDate>
		<dc:creator>John Roach</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ip home automation project]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[paramiko]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://johnroach.info/?p=97</guid>
		<description><![CDATA[If you have been following this blog you probably knew that this post was coming. I have been able to use SSH and Python together with some dependencies. These dependencies are Paramiko from http://www.lag.net/paramiko/ and a python sript (which I &#8230; <a href="http://johnroach.info/2009/10/31/workflow-of-the-blackbox-system-and-connecting-in-two-steps-pythonssh/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you have been following this blog you probably knew that this post was coming. I have been able to use SSH and Python together with some dependencies. These dependencies are Paramiko from <a href="http://www.lag.net/paramiko/ " target="_blank">http://www.lag.net/paramiko/</a> and a python sript (which I had to edit more on that later) which was written by Zeth from  <a href="http://commandline.org.uk" target="_blank">http://commandline.org.uk</a>.</p>
<p>In this short time using python let me say that it is a very organic programming language that should bring happiness to all programmer that have been muddling with other scripting languages. Saying that let&#8217;s go back to business.</p>
<p style="text-align: left;">Because I changed from Telnet to SSH some things had to change. A new design frenzy ensued. And the result was as below.</p>
<div id="attachment_98" class="wp-caption aligncenter" style="width: 583px"><a href="http://johnroach.info/wp-content/uploads/2009/10/connectionsteps.png"><img class="size-large wp-image-98  " title="connectionsteps" src="http://johnroach.info/wp-content/uploads/2009/10/connectionsteps-1024x640.png" alt="connectionsteps" width="573" height="358" /></a><p class="wp-caption-text">connectionsteps</p></div>
<p>Please click on the image above to see it more clearly.</p>
<p style="text-align: left;">So let my explain the above flow step by step.</p>
<p><span id="more-97"></span></p>
<p style="text-align: left;">First of all let us first check out the dependencies. The first dependency is Paramiko. You can download it from <a href="http://www.lag.net/paramiko/ " target="_blank">http://www.lag.net/paramiko/</a>. Paramiko has two dependencies. Phython and pycrypto. You can get pycrypto by using</p>
<p><code>#yum install python-pycrypto*</code></p>
<p style="text-align: left;">or</p>
<p><code>#yum install pycrypto</code></p>
<p>If none of the above work than you have to do it the hardware. I myself built pycrypto and paramiko myself. I used no RPM packages. For that I am proud of myself. However if you really need the rpm packages for paramiko you can find it from <a href="http://dag.wieers.com/rpm/packages/python-paramiko/" target="_blank">http://dag.wieers.com/rpm/packages/python-paramiko/</a>.</p>
<p>So now you have Paramiko. However you will quickly notice that learning all the nice things that Paramiko does takes time and if you are hard-pressed on time like me you can simply download a friendly Python SSH2 interface written by Zeth from <a href="http://commandline.org.uk/" target="_blank">http://commandline.org.uk</a>.</p>
<p>Now let&#8217;s first check this interface ;</p>
<pre  name="code" class="python">"""Friendly Python SSH2 interface."""
"""Created by Zeth from  http://commandline.org.uk"""
"""Edited by John Roach from http://johnroach.info"""

import os
import tempfile
import paramiko
import sys

class Connection(object):
"""Connects and logs into the specified hostname.
Arguments that are not given are guessed from the environment."""

def __init__(self,
host,
username = None,
private_key = None,
password = None,
port = 22,
):
self._sftp_live = False
self._sftp = None
if not username:
username = os.environ['LOGNAME']

# Log to a temporary file.
templog = tempfile.mkstemp('.txt', 'ssh-')[1]
paramiko.util.log_to_file(templog)

# Begin the SSH transport.
self._transport = paramiko.Transport((host, port))
self._tranport_live = True
# Authenticate the transport.
if password:
# Using Password.
self._transport.connect(username = username, password = password)
else:
# Use Private Key.
if not private_key:
# Try to use default key.
if os.path.exists(os.path.expanduser('~/.ssh/id_rsa')):
private_key = '~/.ssh/id_rsa'
elif os.path.exists(os.path.expanduser('~/.ssh/id_dsa')):
private_key = '~/.ssh/id_dsa'
else:
raise (TypeError, "You have not specified a password or key.")

private_key_file = os.path.expanduser(private_key)
rsa_key = paramiko.RSAKey.from_private_key_file(private_key_file)
self._transport.connect(username = username, pkey = rsa_key)

def _sftp_connect(self):
"""Establish the SFTP connection."""
if not self._sftp_live:
self._sftp = paramiko.SFTPClient.from_transport(self._transport)
self._sftp_live = True

def get(self, remotepath, localpath = None):
"""Copies a file between the remote host and the local host."""
if not localpath:
localpath = os.path.split(remotepath)[1]
self._sftp_connect()
self._sftp.get(remotepath, localpath)

def put(self, localpath, remotepath = None):
"""Copies a file between the local host and the remote host."""
if not remotepath:
remotepath = os.path.split(localpath)[1]
self._sftp_connect()
self._sftp.put(localpath, remotepath)

def execute(self, command):
"""Execute the given commands on a remote machine."""
channel = self._transport.open_session()
channel.exec_command(command)
output = channel.makefile('rb', -1).readlines()
if output:
"""This line has been added to ssh.py by John Roach"""
for line in output:
print (line.strip('\n'))
"""This line has been added to ssh.py by John Roach"""
return output
else:
return channel.makefile_stderr('rb', -1).readlines()

def close(self):
"""Closes the connection and cleans up."""
# Close SFTP Connection.
if self._sftp_live:
self._sftp.close()
self._sftp_live = False
# Close the SSH Transport.
if self._tranport_live:
self._transport.close()
self._tranport_live = False

def __del__(self):
"""Attempt to clean up if not explicitly closed."""
self.close()

def main():
"""Little test when called directly."""
# Set these to your own details.
myssh = Connection('example.com')
myssh.put('ssh.py')
myssh.close()

# start the ball rolling.
if __name__ == "__main__":
main()</pre>
<p>So you can see above what I changed. I simply added a way to get the output of any SSH command.</p>
<p>The other dependency for my main program is functions.py this is where I hold my functions so the main Python file can be easier to read. I don&#8217;t know if this is good practice or not in Python programming language. But I thought I looked more pleasing like this.</p>
<p>Hence let&#8217;s check out our functions.py file;</p>
<pre  name="code" class="python">import os
import sys
import urllib
import re

class func(object):

def getMacAddress(self, type):
"""
This has been added by John Roach.
works in both windows and linux
Why Windows? Because I can!!!
"""

if sys.platform == 'win32':
for line in os.popen("ipconfig /all"):
if line.lstrip().startswith('Physical Address'):
mac = line.split(':')[1].strip().replace('-',':')
break
else:
for line in os.popen("/sbin/ifconfig"):
if line.find(type) &gt; -1:
mac = line.split()[4]
break
return mac

def getIPAddress(self):
"""
This program gets your external ip
from whatismyip.com
this program must be called every
5 minutes not more or else you must
have your own server.
"""
site = urllib.urlopen("http://www.whatismyip.com/automation/n09230945.asp").read()
grab = re.findall('\d{2,3}.\d{2,3}.\d{2,3}.\d{2,3}',site)
address = grab[0]
return address</pre>
<p>Probably need some explaining on the functions. <strong>getMacAddress</strong> simply gets the MAC address of the embedded board. This function can work on both Windows and Linux. Why? Because I can! <img src='http://johnroach.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  <strong>getIPAddress </strong>finds out your external address. You must remember if you did the simple host trick in python you will get your LAN IP. However what I needed was the external address. So I simple steal it from www.whatismyip.com. These functions are called within the main program.</p>
<p>So atlast. The main program sshtry.py ;</p>
<pre  name="code" class="python">import ssh
import functions

""" This connection is basicly to the server                    """
""" For testing this is basicly my desktop-computer running     """
""" A special user has been created for this project with       """
""" limited privilages this user is johnroach                   """
""" The IP of the server is IP                       """
s = ssh.Connection(host = 'IP, username = 'username', password = 'passowrd')

""" Calling the functions functions <img src='http://johnroach.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  """
f = functions.func()

"""          Get MAC           """
"""Ethernet = eth  Wi-Fi = wlan"""
mac = f.getMacAddress(type = 'wlan')

"""          Get IP         """
ip = f.getIPAddress()

s.execute('python getip.py '+mac+' '+ip)

s.close()</pre>
<p>I bet you can guess what this program does. But please remember getip.py is actually in the server and is called using SSH.</p>
<p>So now we finished with the embedded device side of the problem. Now we have to see what happens in the server side.</p>
<p>The server side programs ( getipmac.py ) dependencies are different. We really don&#8217;t need SSH and we are simply going to connect to the MySQL database. For this we use a interface named MySQLdb. MySQLdb can be downloaded from http://sourceforge.net/projects/mysql-python/ or simply installed by using<br />
<code><br />
#yum install mysql-python<br />
</code><br />
getipmac.py simply gets the MAC and IP address of the embedded device and stores it in the database. The two parameters are called when the scripts is executed. The program is as below;</p>
<pre name="code"  class="python">import sys
import MySQLdb

if len(sys.argv)!=3:
"""the program name, mac and ip makes three"""
"""stop program and send error"""
sys.exit("Must provide mac and ip!")

mac = sys.argv[1]
ip = sys.argv[2]

try:
conn = MySQLdb.connect (host = "localhost", user = "user", passwd = "pass", db = "theblackbox")
except MySQLdb.Error, e:
print ("Error %d: %s" % (e.args[0], e.args[1]))
sys.exit(1)

cursor = conn.cursor()

cursor.execute ("""UPDATE mac_list SET ip = %s WHERE mac = %s """, (ip, mac))

print ("Number of rows updated: %d" % cursor.rowcount)

cursor.close ()
conn.commit ()
conn.close ()</pre>
<p>Ah so we have reached the end. If you have any questions from above feel free to ask. The program works fine. Now I have to code a chat server like script in python and make it work with PHP. If you look back at the top you will see what I mean. More will come!</p>
]]></content:encoded>
			<wfw:commentRss>http://johnroach.info/2009/10/31/workflow-of-the-blackbox-system-and-connecting-in-two-steps-pythonssh/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Knowing when to fold ( i.e. SSH is better than Telnet )</title>
		<link>http://johnroach.info/2009/10/28/knowing-when-to-fold-i-e-ssh-is-better-than-telnet/</link>
		<comments>http://johnroach.info/2009/10/28/knowing-when-to-fold-i-e-ssh-is-better-than-telnet/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 16:08:45 +0000</pubDate>
		<dc:creator>John Roach</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ip home automation project]]></category>
		<category><![CDATA[embedded device]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php ssh connection]]></category>
		<category><![CDATA[php telnet connection]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[telnet]]></category>

		<guid isPermaLink="false">http://johnroach.info/?p=93</guid>
		<description><![CDATA[You have probably seen my  previous post on connecting to Telnet through PHP although it was a novel idea I have just learned that (from a Novell site. No pun intended.) Telnet is very insecure!! To make things clearer Telnet &#8230; <a href="http://johnroach.info/2009/10/28/knowing-when-to-fold-i-e-ssh-is-better-than-telnet/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>You have probably seen my  previous post on connecting to Telnet through PHP although it was a novel idea I have just learned that (from a Novell site. No pun intended.) Telnet is very insecure!! To make things clearer Telnet usually creates connections as below;</p>
<p style="text-align: center;"><a href="http://johnroach.info/wp-content/uploads/2009/10/Telnet-Client-server-unencrypted.png"><img class="aligncenter size-full wp-image-111" title="Telnet-Client-server-unencrypted" src="http://johnroach.info/wp-content/uploads/2009/10/Telnet-Client-server-unencrypted.png" alt="Telnet-Client-server-unencrypted" width="305" height="209" /></a></p>
<p style="text-align: left;">Up here you can see a hacker can sniff the client-server connection and actually steal the user name and password sent by client. This really won&#8217;t do since if someone can spoof/hack/attack our embedded system which we will be adding to home appliances things may go awry. i.e. you will start seeing automated vacuum cleaners attacking your cat. ( Statistics show that H4X0Rz hate cats. )</p>
<p style="text-align: left;">Hence we can clearly see we need another way for the server and client to talk to each other. After some short Googling I am thinking of using SSH which is native to Linux/Unix based systems. Where the connection will be as below ;</p>
<p style="text-align: left;"><a href="http://johnroach.info/wp-content/uploads/2009/10/SSH-client-server-encrypted.png"><img class="aligncenter size-full wp-image-112" title="SSH-client-server-encrypted" src="http://johnroach.info/wp-content/uploads/2009/10/SSH-client-server-encrypted.png" alt="SSH-client-server-encrypted" width="305" height="209" /></a>As you can see the SSH encryption creates a safer environment for the client and the server plus any DNS attacks and eavesdropping is clearly impossible. (if not probable.)</p>
<p style="text-align: left;">Henceforth a new PHP and Python (this time I will write the server+client in Python) shall be written. Please expect updates.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnroach.info/2009/10/28/knowing-when-to-fold-i-e-ssh-is-better-than-telnet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Connecting to PHP using telnet and sending data to the same port using Java</title>
		<link>http://johnroach.info/2009/10/25/connecting-php-using-telnet-and-sending-data-to-the-same-port-using-java/</link>
		<comments>http://johnroach.info/2009/10/25/connecting-php-using-telnet-and-sending-data-to-the-same-port-using-java/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 10:13:26 +0000</pubDate>
		<dc:creator>John Roach</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ip home automation project]]></category>
		<category><![CDATA[embedded device]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php telnet connection]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[telnet]]></category>
		<category><![CDATA[thread]]></category>

		<guid isPermaLink="false">http://johnroach.info/?p=71</guid>
		<description><![CDATA[Hi there! Have been busy busy busy. What I needed was a way to the following; Above you are looking at a very simple layout. ( Almost childishly simple ) The embedded device has Linux installed with a supposedly very &#8230; <a href="http://johnroach.info/2009/10/25/connecting-php-using-telnet-and-sending-data-to-the-same-port-using-java/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hi there! Have been busy busy busy. What I needed was a way to the following;<br />
<a href="http://johnroach.info/wp-content/uploads/2009/10/graf.png"><img class="size-medium wp-image-72 aligncenter" title="Very Simple Layout" src="http://johnroach.info/wp-content/uploads/2009/10/graf-300x225.png" alt="Very Simple Layout" width="300" height="225" /></a>Above you are looking at a very simple layout. ( Almost childishly simple ) The embedded device has Linux installed with a supposedly very light JVM ( Java Virtual Machine ) So if I am to send data to and from the server and display it to the user I have to do some scripting both in Java and in PHP. Let us first take a look at our universal Java-Socket program which basically opens and listens to a certain port (socket );</p>
<p><span id="more-71"></span></p>
<pre name="code" class="java">
import java.io.*;
import java.net.*;

//This program will listen to port 8189

public class ThreadedEchoServer{

 public static void main (String[] args){

 try{

 int i =1;
 ServerSocket s = new ServerSocket(8189);

 for (;;)
 {  
 Socket incoming = s.accept( );
 System.out.println("Spawning " + i);
 Thread t = new ThreadedEchoHandler(incoming, i);
 t.start();
 i++;
 }

 }catch (Exception e){

 e.printStackTrace();

 }

 }

}
/**
This class handles the client input for one server socket
connection.
*/
class ThreadedEchoHandler extends Thread
{
/**
 Constructs a handler.
 @param i the incoming socket
 @param c the counter for the handlers (used in prompts)
*/
public ThreadedEchoHandler(Socket i, int c)
{
 incoming = i; counter = c;
}

public void run()
{  
 try
 {  
 BufferedReader in = new BufferedReader
 (new InputStreamReader(incoming.getInputStream()));
 PrintWriter out = new PrintWriter
 (incoming.getOutputStream(), true /* autoFlush */);

 out.println( "Hello! Enter BYE to exit." );

 boolean done = false;
 while (!done)
 {  
 String str = in.readLine();
 if (str == null) done = true;
 else
 {  
 // out.println("Echo (" + counter + "): " + str);
 out.println("Connected to : " + str + "&lt;br/&gt;");
 //this is where you get the dang str!!! that is sent by embedded  device.
 //OR this is where you get the configurations from php server on the embedded device.
 System.out.println("Php server sent the following string :"+str);

 if (str.trim().equals("BYE"))
 done = true;
 }
 }
 incoming.close();
 }
 catch (Exception e)
 {  
 e.printStackTrace();
 }
}

private Socket incoming;
private int counter;
}
</pre>
<p>So we have finished with the Java code. Which both can be installed in the server or the embedded device. Notice that the port is  8189. Let us assume that this nice piece of work is on the embedded device. Now we have to send commands to and from the device via PHP using a telnet like protocol. That is when I started searching Google. Came up with a nice site <a href="http://www.geckotribe.com/php-telnet/" target="_blank">http://www.geckotribe.com/php-telnet/</a></p>
<p>A nice site if you want to send data to and from telnet. And indeed it was what I needed. However I needed to do some modifications to the code they provided. The code below belongs to them;</p>
<p>(PHPTelnet.php)</p>
<pre name="code" class="php">
&lt;?php
/*
PHPTelnet
*/

class PHPTelnet {
 var $show_connect_error=1;

 var $use_usleep=1;    // change to 1 for faster execution default:0
 // don't change to 1 on Windows servers unless you have PHP 5
 var $sleeptime=125000;
 var $loginsleeptime=1000000;

 var $fp=NULL;
 var $loginprompt;

 var $conn1;
 var $conn2;

 /*
 0 = success
 1 = couldn't open network connection
 2 = unknown host
 3 = login failed
 4 = PHP version too low
 */
 function Connect($server,$user,$pass) {
 $rv=0;
 $vers=explode('.',PHP_VERSION);
 $needvers=array(4,3,0);
 $j=count($vers);
 $k=count($needvers);
 if ($k&lt;$j) $j=$k;
 for ($i=0;$i&lt;$j;$i++) {
 if (($vers[$i]+0)&gt;$needvers[$i]) break;
 if (($vers[$i]+0)&lt;$needvers[$i]) {
 $this-&gt;ConnectError(4);
 return 4;
 }
 }

 $this-&gt;Disconnect();

 if (strlen($server)) {
 if (preg_match('/[^0-9.]/',$server)) {
 $ip=gethostbyname($server);
 if ($ip==$server) {
 $ip='';
 $rv=2;
 }
 } else $ip=$server;
 } else $ip='127.0.0.1';

 if (strlen($ip)) {
 if ($this-&gt;fp=fsockopen($ip,8189))
 {

 if( ($user!="")&amp;&amp; ($pass!=""))
 {
 fputs($this-&gt;fp,$this-&gt;conn1);
 $this-&gt;Sleep();

 fputs($this-&gt;fp,$this-&gt;conn2);
 $this-&gt;Sleep();
 $this-&gt;GetResponse($r);
 $r=explode("\n",$r);
 $this-&gt;loginprompt=$r[count($r)-1];

 fputs($this-&gt;fp,"$user\r");
 $this-&gt;Sleep();

 fputs($this-&gt;fp,"$pass\r");
 if ($this-&gt;use_usleep) usleep($this-&gt;loginsleeptime);
 else sleep(1);
 $this-&gt;GetResponse($r);
 $r=explode("\n",$r);
 if (($r[count($r)-1]=='')||($this-&gt;loginprompt==$r[count($r)-1])) {
 $rv=3;
 $this-&gt;Disconnect();
 }

 }
 } else $rv=1;
 }

 if ($rv) $this-&gt;ConnectError($rv);
 return $rv;
 }

 function Disconnect($exit=1) {
 if ($this-&gt;fp) {
 if ($exit) $this-&gt;DoCommand('exit',$junk);
 fclose($this-&gt;fp);
 $this-&gt;fp=NULL;
 }
 }

 function DoCommand($c,&amp;$r) {
 if ($this-&gt;fp) {
 fputs($this-&gt;fp,"$c\r");
 $this-&gt;Sleep();
 $this-&gt;GetResponse($r);
 $r=preg_replace("/^.*?\n(.*)\n[^\n]*$/","$1",$r);
 }
 return $this-&gt;fp?1:0;
 }

 function GetResponse(&amp;$r) {
 $r='';
 do {
 $r.=fread($this-&gt;fp,1000);
 $s=socket_get_status($this-&gt;fp);
 } while ($s['unread_bytes']);
 }

 function Sleep() {
 if ($this-&gt;use_usleep) usleep($this-&gt;sleeptime);
 else sleep(1);
 }

 function PHPTelnet() {
 $this-&gt;conn1=chr(0xFF).chr(0xFB).chr(0x1F).chr(0xFF).chr(0xFB).
 chr(0x20).chr(0xFF).chr(0xFB).chr(0x18).chr(0xFF).chr(0xFB).
 chr(0x27).chr(0xFF).chr(0xFD).chr(0x01).chr(0xFF).chr(0xFB).
 chr(0x03).chr(0xFF).chr(0xFD).chr(0x03).chr(0xFF).chr(0xFC).
 chr(0x23).chr(0xFF).chr(0xFC).chr(0x24).chr(0xFF).chr(0xFA).
 chr(0x1F).chr(0x00).chr(0x50).chr(0x00).chr(0x18).chr(0xFF).
 chr(0xF0).chr(0xFF).chr(0xFA).chr(0x20).chr(0x00).chr(0x33).
 chr(0x38).chr(0x34).chr(0x30).chr(0x30).chr(0x2C).chr(0x33).
 chr(0x38).chr(0x34).chr(0x30).chr(0x30).chr(0xFF).chr(0xF0).
 chr(0xFF).chr(0xFA).chr(0x27).chr(0x00).chr(0xFF).chr(0xF0).
 chr(0xFF).chr(0xFA).chr(0x18).chr(0x00).chr(0x58).chr(0x54).
 chr(0x45).chr(0x52).chr(0x4D).chr(0xFF).chr(0xF0);
 $this-&gt;conn2=chr(0xFF).chr(0xFC).chr(0x01).chr(0xFF).chr(0xFC).
 chr(0x22).chr(0xFF).chr(0xFE).chr(0x05).chr(0xFF).chr(0xFC).chr(0x21);
 }

 function ConnectError($num) {
 if ($this-&gt;show_connect_error) switch ($num) {
 case 1: echo '&lt;br /&gt;[PHP Telnet] &lt;a href="http://www.geckotribe.com/php-telnet/errors/fsockopen.php"&gt;Connect failed: Unable to open network connection&lt;/a&gt;&lt;br /&gt;'; break;
 case 2: echo '&lt;br /&gt;[PHP Telnet] &lt;a href="http://www.geckotribe.com/php-telnet/errors/unknown-host.php"&gt;Connect failed: Unknown host&lt;/a&gt;&lt;br /&gt;'; break;
 case 3: echo '&lt;br /&gt;[PHP Telnet] &lt;a href="http://www.geckotribe.com/php-telnet/errors/login.php"&gt;Connect failed: Login failed&lt;/a&gt;&lt;br /&gt;'; break;
 case 4: echo '&lt;br /&gt;[PHP Telnet] &lt;a href="http://www.geckotribe.com/php-telnet/errors/php-version.php"&gt;Connect failed: Your server\'s PHP version is too low for PHP Telnet&lt;/a&gt;&lt;br /&gt;'; break;
 }
 }
}

return;
?&gt;
</pre>
<p>However because I needed something that used a different port had to change the port number if you look at the comments in the form you will see where I edited the code.</p>
<p>Also because my Telnet was without a password ( i wanted to test it first) I added an &#8220;if&#8221; statement. Now to the index.php code;</p>
<pre name="code" class="php">
&lt;html&gt;&lt;head&gt;&lt;title&gt;&lt;/title&gt;&lt;/head&gt;&lt;body&gt;

&lt;?php

require_once "PHPTelnet.php";

$telnet = new PHPTelnet();

// if the first argument to Connect is blank,
// PHPTelnet will connect to the local host via 127.0.0.1
// the second blank is for the username (may be for embedded device)
// the third blank is for the password (may be for embedded device)
$result = $telnet-&gt;Connect('','','');

if ($result == 0) {
$telnet-&gt;DoCommand('The embedded device!!', $result);
// NOTE: $result may contain newlines
echo $result;
$telnet-&gt;DoCommand('BYE', $result);
echo $result;
// say Disconnect(0); to break the connection without explicitly logging out
$telnet-&gt;Disconnect();
}

?&gt;
&lt;/body&gt;&lt;/html&gt;</pre>
<p>Now to run a test; first run the Java program ( I hope you know how to compile and run a java program from console.) And than simply open index.php ( of course from Apache! ) And voilà!! you have a program that can connect directly to a php server page!!</p>
<p>Questions? Comments just send it in!</p>
]]></content:encoded>
			<wfw:commentRss>http://johnroach.info/2009/10/25/connecting-php-using-telnet-and-sending-data-to-the-same-port-using-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

