<?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; programming</title>
	<atom:link href="http://johnroach.info/tag/programming/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>From the beginning please</title>
		<link>http://johnroach.info/2010/10/11/from-the-beginning-please/</link>
		<comments>http://johnroach.info/2010/10/11/from-the-beginning-please/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 15:24:10 +0000</pubDate>
		<dc:creator>John Roach</dc:creator>
				<category><![CDATA[just fun]]></category>
		<category><![CDATA[grandpa]]></category>
		<category><![CDATA[IBM]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[john roach]]></category>
		<category><![CDATA[Jython]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[renko]]></category>

		<guid isPermaLink="false">http://johnroach.info/?p=382</guid>
		<description><![CDATA[Hi there. Summer over and so is my work with the company RENKO ITH.  IHR. LTD. STI.. Worked for peanuts doing lots. Proud of it. Paid my school tuition with the peanuts. I think this makes my school a three &#8230; <a href="http://johnroach.info/2010/10/11/from-the-beginning-please/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hi there. Summer over and so is my work with the company RENKO ITH.  IHR. LTD. STI.. Worked for peanuts doing lots. Proud of it. Paid my school tuition with the peanuts. I think this makes my school a <a class="zem_slink" title="Circus" rel="wikipedia" href="http://en.wikipedia.org/wiki/Circus">three ring circus</a> <img src='http://johnroach.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<p>Work was good and honest in RENKO. I wore three hats at all times ;</p>
<p><span id="more-382"></span></p>
<p style="padding-left: 60px;"><strong>Hat#1. </strong>Software Engineer/Programmer : Basically I wrote one main program and couple of dozen other programs. The main program used the following languages; <a class="zem_slink" title="Python (programming language)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">Python</a>, <a class="zem_slink" title="PHP" rel="wikipedia" href="http://en.wikipedia.org/wiki/PHP">PHP</a>, C, <a class="zem_slink" title="JavaScript" rel="wikipedia" href="http://en.wikipedia.org/wiki/JavaScript">JavaScript</a>. The small scripts I wrote used <a class="zem_slink" title="Jython" rel="wikipedia" href="http://en.wikipedia.org/wiki/Jython">Jython</a>. And as for what these programs did; <a class="zem_slink" title="Picasa" rel="homepage" href="http://picasa.google.com/">Picassa</a> and/or <a class="zem_slink" title="Flickr" rel="homepage" href="http://flickr.com">Flickr</a> like internet site. Processed image.</p>
<p style="padding-left: 60px;"><strong>Hat#2. </strong><a class="zem_slink" title="Network engineer" rel="wikipedia" href="http://en.wikipedia.org/wiki/Network_engineer">Network Engineer</a> : As you may have read from <a href="http://johnroach.info/2010/06/being-the-master-of-a-ibm-x3200/" target="_blank">the previous post</a> I set up an <a class="zem_slink" title="IBM" rel="wikipedia" href="http://en.wikipedia.org/wiki/IBM">IBM</a> server and changed the whole <a class="zem_slink" title="Network topology" rel="wikipedia" href="http://en.wikipedia.org/wiki/Network_topology">network topology</a>. (Argh! moment here) Lots of manual labor. However now the company has a faster and secured network. My biggest problem was parts. Network parts are really expensive. And trying to do it cheap is really hard.</p>
<p style="padding-left: 60px;"><strong>Hat#3. </strong>Floor manager in a photo shop : Yeah you heard it here, John Roach worked as a mean guy trying to sell wedding photos to young couples. This hat I must admit I didn&#8217;t really like. Not because it was hard or it was all about selling. But because the person before me was just so&#8230; how can I put it politically correct&#8230; basically he was messy. Can&#8217;t tell everything on the internet can we?</p>
<p>Just because I worked hard doesn&#8217;t mean I didn&#8217;t have fun. I had lots of it. And learned a lot! The one thing I am proud to say I have learned is Jython! What a quick fix language! And the other thing is Image processing. A hands out to <a class="zem_slink" title="OpenCV" rel="wikipedia" href="http://en.wikipedia.org/wiki/OpenCV">Open-CV</a> and Python Image Library (PIL).</p>
<p>And talking of a good summer. My grandpa came all the way from a far land called USA. This his first visit to Turkey! So we are very happy to have him. We are trying to con him in to staying here in Turkey.  Me and my brother already has plans to hide his tickets and shoes. Don&#8217;t know if it will work or not. Mom will probably catch up to us. Meh&#8230; My love met my grandfather. They seemed to like each other which is also good <img src='http://johnroach.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Below you will see images from my work place and my love with grandpa. Enjoy!</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="host=picasaweb.google.com&amp;hl=en_GB&amp;feat=flashalbum&amp;RGB=0x000000&amp;feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fjohnroach1985%2Falbumid%2F5526800870689483185%3Falt%3Drss%26kind%3Dphoto%26hl%3Den_GB" /><param name="src" value="http://picasaweb.google.com/s/c/bin/slideshow.swf" /><embed type="application/x-shockwave-flash" width="600" height="400" src="http://picasaweb.google.com/s/c/bin/slideshow.swf" flashvars="host=picasaweb.google.com&amp;hl=en_GB&amp;feat=flashalbum&amp;RGB=0x000000&amp;feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fjohnroach1985%2Falbumid%2F5526800870689483185%3Falt%3Drss%26kind%3Dphoto%26hl%3Den_GB"></embed></object></p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/zemified_e.png?x-id=c4453c81-b8a4-4d0d-836d-fc96365ac4aa" alt="Enhanced by Zemanta" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://johnroach.info/2010/10/11/from-the-beginning-please/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Summer Project &#8220;OpenIntelligentRobot&#8221;  and Help Needed!</title>
		<link>http://johnroach.info/2010/05/25/summer-project-openintelligentrobot-help-needed/</link>
		<comments>http://johnroach.info/2010/05/25/summer-project-openintelligentrobot-help-needed/#comments</comments>
		<pubDate>Tue, 25 May 2010 14:33:19 +0000</pubDate>
		<dc:creator>John Roach</dc:creator>
				<category><![CDATA[summer project 2010]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[beagleboard]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[robot]]></category>

		<guid isPermaLink="false">http://johnroach.info/?p=280</guid>
		<description><![CDATA[I&#8217;ve been mulling over an idea all winter. Trying to come up with different projects that could be done using Beagle-board and Arduino. The project is (you hear drum-roll here) &#8220;Building An Intelligent Robot&#8221;. I know it&#8217;s already been done however I have some &#8230; <a href="http://johnroach.info/2010/05/25/summer-project-openintelligentrobot-help-needed/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been mulling over an idea all winter. Trying to come up with different projects that could be done using Beagle-board and Arduino. The project is (you hear drum-roll here) &#8220;Building An Intelligent Robot&#8221;. I know it&#8217;s already been done however I have some additional ideas to put in project. All code will be open source. So if you want to build your own you could read up in this site.Oh and I really do need help. Especially financially. So if you are interested please drop me a line. My doodling is as below to give you an idea.<br />
<a href="http://johnroach.info/wp-content/uploads/2010/05/summer_plan.jpg"><img src="http://johnroach.info/wp-content/uploads/2010/05/summer_plan-744x1024.jpg" alt="" title="summer_plan" width="744" height="1024" class="aligncenter size-large wp-image-285" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://johnroach.info/2010/05/25/summer-project-openintelligentrobot-help-needed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing size of array in C programming language</title>
		<link>http://johnroach.info/2010/04/17/changing-size-of-array-in-c-programming-language/</link>
		<comments>http://johnroach.info/2010/04/17/changing-size-of-array-in-c-programming-language/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 09:59:44 +0000</pubDate>
		<dc:creator>John Roach</dc:creator>
				<category><![CDATA[Coding for fun]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://johnroach.info/?p=266</guid>
		<description><![CDATA[It&#8217;s been a long time since I coded in C. I needed to change the size of an array within the program. At first I just simply tried; int ab=10; int array[ab]; And surprisingly it didn&#8217;t work. (I mean it &#8230; <a href="http://johnroach.info/2010/04/17/changing-size-of-array-in-c-programming-language/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a long time since I coded in C. I needed to change the size of an array within the program. At first I just simply tried;</p>
<pre name="code" class="c">
int ab=10;
int array[ab];
</pre>
<p>And surprisingly it didn&#8217;t work. (I mean it works in C++ and C#)<br />
Anyway I was thinking of ways on how to do this thought of using malloc() however I really didn&#8217;t know how hence I did some Google&#8217;ing around. And found this neat piece of code.</p>
<pre name="code" class="c">
int *resize_array(int *a, size_t new_size)
{
  int *save;

  save = realloc(a, new_size);
  if (save == NULL) {
    fprintf(stderr, "Memory exhausted\n");
    exit(EXIT_FAILURE);
  }
  return save;
}

int *user_old_array; // the array
int new_array_size=10;
user_old_array = malloc(initial_array_size * sizeof *user_old_array); //resized array
</pre>
<p>Quite neat isn&#8217;t it. I thought I should probably write this somewhere so I won&#8217;t forget. Hence the post.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://johnroach.info/2010/04/17/changing-size-of-array-in-c-programming-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AM and DSB-SC Modulation and Demodulation of a Periodic Square Wave (Matlab)</title>
		<link>http://johnroach.info/2009/11/15/am-and-dsb-sc-modulation-and-demodulation-of-a-periodic-square-wave-matlab/</link>
		<comments>http://johnroach.info/2009/11/15/am-and-dsb-sc-modulation-and-demodulation-of-a-periodic-square-wave-matlab/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 15:49:00 +0000</pubDate>
		<dc:creator>John Roach</dc:creator>
				<category><![CDATA[Coding for fun]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[demodulation]]></category>
		<category><![CDATA[john roach]]></category>
		<category><![CDATA[matlab]]></category>
		<category><![CDATA[modulation]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://johnroach.info/?p=127</guid>
		<description><![CDATA[We once had a homework way back when decided to share it. I edited this script which is in Matlab. I hope you like it. It simply is an analysis of AM and DSB-SC Modulation and Demodulation of a Periodic &#8230; <a href="http://johnroach.info/2009/11/15/am-and-dsb-sc-modulation-and-demodulation-of-a-periodic-square-wave-matlab/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We once had a homework way back when decided to share it. I edited this script which is in Matlab. I hope you like it. It simply is an analysis of AM and DSB-SC Modulation and Demodulation of a Periodic Square Wave.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
</pre></td><td class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #228B22;">%Amplitude Modulation with a periodic sqare wave and its spectrum analysis</span>
<span style="color: #228B22;">%Show the time domain and frquency domain representation of DSB-AM and</span>
<span style="color: #228B22;">%DSB-SC modulations</span>
<span style="color: #228B22;">%By : John Roach – 6 March 2009</span>
<span style="color: #228B22;">%visit my site at http://johnroach.info</span>
N = <span style="color: #33f;">1024</span>; <span style="color: #228B22;">%N point FFT N&gt;fc to avoid freq domain aliasing</span>
fs = <span style="color: #33f;">4096</span>; <span style="color: #228B22;">% Sample frequency</span>
t = <span style="color: #080;">&#40;</span><span style="color: #33f;">0</span>:N-<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>/fs;
fc = <span style="color: #33f;">600</span>; <span style="color: #228B22;">%Carrier Frequency</span>
fm2 = <span style="color: #33f;">80</span>; <span style="color: #228B22;">%Message Frequency</span>
Ec = <span style="color: #33f;">20</span>; <span style="color: #228B22;">%Carrier Amplitude</span>
Em2 = <span style="color: #33f;">5</span>; <span style="color: #228B22;">%Messagae Amplitude</span>
<span style="color: #228B22;">% Try changing the message and carrier amplitudes to see the effect in</span>
<span style="color: #228B22;">% DSB-AM modulation</span>
<span style="color: #228B22;">%———Double SideBand Full Carrier Modulation (DSB-FC(AM))</span>
A = Ec + Em2*square<span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>*<span style="color: #0000FF;">pi</span>*fm2*t<span style="color: #080;">&#41;</span>;<span style="color: #228B22;">%Envelope/eliminate the carrier amplitude</span>
m = A.*<span style="color: #0000FF;">sin</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>*<span style="color: #0000FF;">pi</span>*fc*t<span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%to convert DSB-AM to DSB-SC</span>
Mf = <span style="color: #33f;">2</span>/N*<span style="color: #0000FF;">abs</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">fft</span><span style="color: #080;">&#40;</span>m,N<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
f = fs * <span style="color: #080;">&#40;</span><span style="color: #33f;">0</span> : N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span> / N;<span style="color: #228B22;">%Since the fft result is symmetrical, only the</span>
<span style="color: #228B22;">%positive half is sufficient for spectral representation</span>
<span style="color: #0000FF;">close</span> <span style="color: #0000FF;">all</span>;
<span style="color: #0000FF;">figure</span><span style="color: #080;">&#40;</span>’Name’,'Time/Fequency domain representations of DSB-AM signals’<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">subplot</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>,<span style="color: #33f;">1</span>,<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%Time domain plot</span>
<span style="color: #0000FF;">plot</span><span style="color: #080;">&#40;</span>t<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>,m<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>,t<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>,A<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>,’r',t<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>,-A<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>,’r'<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">title</span><span style="color: #080;">&#40;</span>’Time Domain Representation’<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">xlabel</span><span style="color: #080;">&#40;</span>’Time’<span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">ylabel</span><span style="color: #080;">&#40;</span>’Modulated signal’<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">subplot</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>,<span style="color: #33f;">1</span>,<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%Frequency Domain Plot</span>
<span style="color: #0000FF;">plot</span><span style="color: #080;">&#40;</span>f<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:<span style="color: #33f;">256</span><span style="color: #080;">&#41;</span>,Mf<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:<span style="color: #33f;">256</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">title</span><span style="color: #080;">&#40;</span>’Frequency Domain Representation’<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">xlabel</span><span style="color: #080;">&#40;</span>’Frequency <span style="color: #080;">&#40;</span>Hz<span style="color: #080;">&#41;</span>’<span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">ylabel</span><span style="color: #080;">&#40;</span>’Spectral Magnitude’<span style="color: #080;">&#41;</span>;
<span style="color: #228B22;">%———-Double SideBand Suppressed Carrier DSB-SC———-</span>
A = Em2*square<span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>*<span style="color: #0000FF;">pi</span>*fm2*t<span style="color: #080;">&#41;</span> ; <span style="color: #228B22;">%Envelope/eliminate the carrier amplitude</span>
m = A.*<span style="color: #0000FF;">sin</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>*<span style="color: #0000FF;">pi</span>*fc*t<span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%to convert DSB-AM to DSB-SC</span>
Mf = <span style="color: #33f;">2</span>/N*<span style="color: #0000FF;">abs</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">fft</span><span style="color: #080;">&#40;</span>m,N<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">figure</span><span style="color: #080;">&#40;</span>’Name’,'Time/Fequency domain representations of DSB-SC signals’<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">subplot</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>,<span style="color: #33f;">1</span>,<span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%Time domain plot</span>
<span style="color: #0000FF;">plot</span><span style="color: #080;">&#40;</span>t<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>,m<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>,t<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>,A<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>,’r',t<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>,-A<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:N/<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>,’r'<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">title</span><span style="color: #080;">&#40;</span>’Time Domain Representation’<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">xlabel</span><span style="color: #080;">&#40;</span>’Time’<span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">ylabel</span><span style="color: #080;">&#40;</span>’Modulated signal’<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">subplot</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span>,<span style="color: #33f;">1</span>,<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>; <span style="color: #228B22;">%Frequency Domain Plot</span>
<span style="color: #0000FF;">plot</span><span style="color: #080;">&#40;</span>f<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:<span style="color: #33f;">256</span><span style="color: #080;">&#41;</span>,Mf<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:<span style="color: #33f;">256</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">title</span><span style="color: #080;">&#40;</span>’Frequency Domain Representation’<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">xlabel</span><span style="color: #080;">&#40;</span>’Frequency <span style="color: #080;">&#40;</span>Hz<span style="color: #080;">&#41;</span>’<span style="color: #080;">&#41;</span>; <span style="color: #0000FF;">ylabel</span><span style="color: #080;">&#40;</span>’Spectral Magnitude’<span style="color: #080;">&#41;</span>;
text<span style="color: #080;">&#40;</span><span style="color: #33f;">15</span>,<span style="color: #33f;">60</span>,’Carrier’<span style="color: #080;">&#41;</span>;
<span style="color: #228B22;">%——————————————————————–</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://johnroach.info/2009/11/15/am-and-dsb-sc-modulation-and-demodulation-of-a-periodic-square-wave-matlab/feed/</wfw:commentRss>
		<slash:comments>23</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_1795992419_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: 2px 0; border: none; border-width: 1px; border-color: #ffffff; border-style: solid dotted; font: 14px Tahoma; text-decoration: none; background: none; color: #ffffff; background-color: #292929; white-space: nowrap; border-top-left-radius: 8px; border-top-right-radius: 8px; margin-right: -1px; }
.flag_alternate .flagcatlinks a.flagcat:hover { text-decoration: none; background: none; }
.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 {  }
.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>
	<meta content="width=device-width, initial-scale=1.0;" name="viewport" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<link rel="stylesheet" href="http://johnroach.info/wp-content/plugins/flash-album-gallery/admin/js/photoswipe/photoswipe.css" type="text/css" />
	<script type="text/javascript" src="http://johnroach.info/wp-content/plugins/flash-album-gallery/admin/js/photoswipe/klass.min.js"></script>
	<script type="text/javascript" src="http://johnroach.info/wp-content/plugins/flash-album-gallery/admin/js/photoswipe/code.photoswipe.jquery-3.0.4.min.js"></script>
	<script type="text/javascript">var ExtendVar=false;</script>
<div id="sid_1795992419_jq" class="flag_alternate">
		<div class="flagcatlinks"></div>
			<div class="flagCatMeta">
			<h4>BeagleBoardArrival</h4>
			<p></p>
		</div>
		<div class="flagcategory" id="gid_1_sid_1795992419">
			<a class="i0 flag_pic_alt" href="http://johnroach.info/wp-content/flagallery/beagleboardarrival/image023.jpg" id="flag_pic_1" rel="gid_1_sid_1795992419" 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_1795992419" 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_1795992419'] = jQuery("div#sid_1795992419_jq").clone().wrap(document.createElement('div')).parent().html();
var sid_1795992419_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_1795992419",
		postID : "116",
		postTitle : "The+BeagleBoard+Has+Arrived%21%21+"},
	attr : {
		styleclass : "flashalbum",
		id : "sid_1795992419"},
	start : function() {
		swfobject.embedSWF("http://johnroach.info/wp-content/plugins/flagallery-skins/default/gallery.swf", "sid_1795992419_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_1795992419","outline:none");
	}
}
sid_1795992419_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>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>

