<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Just moozing</title>
	<atom:link href="http://moozing.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://moozing.wordpress.com</link>
	<description>Before you can check your notes, you must make them...</description>
	<lastBuildDate>Fri, 06 Jan 2012 16:24:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='moozing.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Just moozing</title>
		<link>http://moozing.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://moozing.wordpress.com/osd.xml" title="Just moozing" />
	<atom:link rel='hub' href='http://moozing.wordpress.com/?pushpress=hub'/>
		<item>
		<title>gstreamer and HTML5</title>
		<link>http://moozing.wordpress.com/2011/12/29/gstreamer-and-html5/</link>
		<comments>http://moozing.wordpress.com/2011/12/29/gstreamer-and-html5/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 08:00:28 +0000</pubDate>
		<dc:creator>moozing</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Camera]]></category>
		<category><![CDATA[gstreamer]]></category>
		<category><![CDATA[HTML5]]></category>

		<guid isPermaLink="false">http://moozing.wordpress.com/?p=434</guid>
		<description><![CDATA[It is fairly trivial to have gstreamer retrieve using HTTP and sending video through sockets. I want to use the video tags from HTML5 to show the gstreamer video. HTTP server I didn&#8217;t find an HTTP server as part of gstreamer. Suggestions include shout2send and tcpserversink, but I wanted a trivial HTTP server. I implemented [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=434&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It is fairly trivial to have gstreamer retrieve using HTTP and sending video through sockets. I want to use the video tags from HTML5 to show the gstreamer video.</p>
<p><span id="more-434"></span></p>
<h1>HTTP server</h1>
<p>I didn&#8217;t find an HTTP server as part of gstreamer. Suggestions include <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-plugin-shout2send.html">shout2send</a> and <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-tcpserversink.html">tcpserversink</a>, but I wanted a trivial HTTP server. I implemented a simple server in Python.</p>
<p><pre class="brush: python; wrap-lines: false;">
import subprocess # for piping
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

class RequestHandler(BaseHTTPRequestHandler):
    def _writeheaders(self):
        self.send_response(200) # 200 OK http response
        self.send_header('Content-type', 'video/ogg')
        self.end_headers()

    def do_HEAD(self):
        self._writeheaders()

    def do_GET(self):
        self._writeheaders()

        DataChunkSize = 10000

        command = '(echo &quot;--video boundary--&quot;; curl -s http://trendnetcam/video.cgi;) | gst-launch fdsrc do-timestamp=true ! multipartdemux boundary=&quot;video boundary--&quot; ! jpegdec ! videorate ! video/x-raw-yuv,framerate=4/1 ! theoraenc ! oggmux !  filesink location=/dev/stdout'
        print(&quot;running command: %s&quot; % (command, ))
        p = subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=-1, shell=True)

        print(&quot;starting polling loop.&quot;)
        while(p.poll() is None):
            print &quot;looping... &quot;
            stdoutdata = p.stdout.read(DataChunkSize)
            self.wfile.write(stdoutdata)

        print(&quot;Done Looping&quot;)

        print(&quot;dumping last data, if any&quot;)
        stdoutdata = p.stdout.read(DataChunkSize)
        self.wfile.write(stdoutdata)

if __name__ == '__main__':
    serveraddr = ('', 8765) # connect to port 8765
    srvr = HTTPServer(serveraddr, RequestHandler)
    srvr.serve_forever()

</pre></p>
<p>The basic idea is to have an webserver running and when a browser connects, gstreamer is started and data is piped as the file content.</p>
<p>The command on line 18 is described in a <a href="http://moozing.wordpress.com/2011/12/28/gstreamer-and-mjpeg/">previous blog</a>.</p>
<h1>The webpage</h1>
<p>The page is accessible on http://localhost:8765 and whatever other IP the machine has (using port 8765). The HTML part could look like this.</p>
<pre>
<pre class="brush: xml;">
&lt;html&gt;
    &lt;title&gt;HTML5 video test page&lt;/title&gt;
&lt;/html&gt;
&lt;body&gt;
    Connection to localhost port 8765 for video stuff. &lt;br /&gt;
    &lt;a href=&quot;http://www.w3schools.com/html5/html5_video.asp&quot;&gt;something about HT$

    &lt;video autoplay&gt;
        &lt;source src=&quot;http://localhost:8765&quot; /&gt;
        Your browser does not support the video tag.
    &lt;/video&gt;
&lt;/body&gt;
</pre>
</pre>
<p>This is a basic HTML page using a video tag. It will show the video in an embedded player. Go<a href="http://www.w3schools.com/html5/html5_video.asp"> here</a> for video tag information.</p>
<h1>More to come?</h1>
<p>There are a lot of stuff that could be improved</p>
<ul>
<li>Security! I just copied from the first example I found. do_POST() might still be implemented and could be used to read files.</li>
<li>Error handling is non-existent.</li>
<li>Currently there is only one thing been served. It could be cool to have dynamic list of streams that could be accessed.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moozing.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moozing.wordpress.com/434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moozing.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moozing.wordpress.com/434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moozing.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moozing.wordpress.com/434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moozing.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moozing.wordpress.com/434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moozing.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moozing.wordpress.com/434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moozing.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moozing.wordpress.com/434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moozing.wordpress.com/434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moozing.wordpress.com/434/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=434&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moozing.wordpress.com/2011/12/29/gstreamer-and-html5/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b26a2570cf4f2ce9d2c3206ebac0a34d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">moozing</media:title>
		</media:content>
	</item>
		<item>
		<title>gstreamer and MJPEG</title>
		<link>http://moozing.wordpress.com/2011/12/28/gstreamer-and-mjpeg/</link>
		<comments>http://moozing.wordpress.com/2011/12/28/gstreamer-and-mjpeg/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 08:00:10 +0000</pubDate>
		<dc:creator>moozing</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Camera]]></category>
		<category><![CDATA[gstreamer]]></category>

		<guid isPermaLink="false">http://moozing.wordpress.com/?p=411</guid>
		<description><![CDATA[I had a lot of trouble getting gstreamer to accept the mjpeg stream and convert it to something HTML5 understands. In the following, I will try to describe how I got it working. Accessing the IP camera I had this running already as part of getting to the virtual camera device, it is described in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=411&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had a lot of trouble getting <a href="http://gstreamer.freedesktop.org/">gstreamer</a> to accept the <a href="http://en.wikipedia.org/wiki/Motion_JPEG">mjpeg</a> stream and convert it to something HTML5 understands. In the following, I will try to describe how I got it working.</p>
<p><span id="more-411"></span></p>
<h1>Accessing the IP camera</h1>
<p>I had this running already as part of getting to the virtual camera device, it is described in this <a title="IP camera, gstreamer and virtual video devices" href="http://moozing.wordpress.com/2011/12/26/ip-camera-gstreamer-and-virtual-video-devices/">blog entry.</a></p>
<p>To show the mjpeg stream I used the following command</p>
<p><pre class="brush: plain; gutter: false;">
$ gst-launch souphttpsrc location=http://trendnetcam/video.cgi timeout=5 ! jpegdec ! autovideosink
</pre></p>
<p>The parts</p>
<ul>
<li><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-souphttpsrc.html"> souphttpsrc</a> location=http://trendnetcam/video.cgi timeout=5: uses http to retrieve data. It has a 5 seconds timeout before it issues an error.</li>
<li><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-jpegdec.html">jpegdec</a>: decodes jpeg images to <a href="http://en.wikipedia.org/wiki/YUV">YUV</a> or other relevant format.</li>
<li><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-autovideosink.html">autovideosink</a>: outputs the video to screen</li>
</ul>
<p>This also worked with the <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-v4l2sink.html">v4l2sink</a>, so I assumed that converting to ogg/theora would be trivial.</p>
<h1>Encoding to something HTML5 may understand</h1>
<p>The examples I found use <a href="http://theora.org/">theora</a> (I lost the links, sorry)</p>
<p><pre class="brush: plain; gutter: false;">
$ gst-launch videotestsrc num-buffers=100 ! theoraenc ! oggmux ! filesink location=testmovie.ogg
</pre></p>
<p>The parts</p>
<ul>
<li><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-videotestsrc.html">videotestsrc</a> num-buffers=100: This is the gstreamer test signal. It is good to know for debugging. The num-buffers parameter means that we terminate after 100 images. Again, good for debugging.</li>
<li><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-theoraenc.html">theoraenc</a>: Converts YUV to a theora stream.</li>
<li><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-oggmux.html">oggmux</a>: This was in the example I found, but it seems to be related to muxing audio and video.</li>
<li><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-plugins/html/gstreamer-plugins-filesink.html">filesink</a> location=testmovie.ogg: Output result to specified file. autovideosink does not support theora, otherwise I would have used that one.</li>
</ul>
<h1>Mjpeg to theora</h1>
<p>Combining the above pipes.</p>
<p><pre class="brush: plain; gutter: false;">
$ gst-launch souphttpsrc location=http://trendnetcam/video.cgi timeout=5 num-buffers=100 ! jpegdec ! theoraenc ! oggmux ! filesink location=testmovie.ogg

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstSoupHTTPSrc:souphttpsrc0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2582): gst_base_src_loop (): /GstPipeline:pipeline0/GstSoupHTTPSrc:souphttpsrc0:
streaming task paused, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
 </pre></p>
<p>So I get an Internal data flow error. That is highly non-informative.</p>
<p>Sometimes I get</p>
<p><pre class="brush: plain; gutter: false;">
$ gst-launch souphttpsrc location=http://trendnetcam/video.cgi timeout=5 num-buffers=100 ! jpegdec ! theoraenc ! oggmux ! filesink location=testmovie.ogg
...
ERROR: from element /GstPipeline:pipeline0/GstSoupHTTPSrc:souphttpsrc0: Cannot connect to destination (trendnetcam)
...
</pre></p>
<p>Apparently, when playing with gstreamer and souphttpsrc I am able to crash the IP camera and make it unavailable. I am considering a firmware upgrade (or a newer camera).</p>
<p>I started googling, and apparently I am not the only one trying to use gstreamer with an IP camera.  Actually, there are several things wrong with the above command &#8211; both the mjpeg stream is flawed and the pipeline itself.</p>
<h1>Making the MJPEG stream conform</h1>
<p>Inspired by this <a href="http://lists.freedesktop.org/archives/gstreamer-devel/2011-November/034124.html">forum post</a>, I concluded that I was &#8220;lucky&#8221; to have jpegdec working directly without using <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-multipartdemux.html">multipartdemux</a>. It takes the stream, detects the boundary between the parts and splits the stream into images. This works for some IP cameras.</p>
<p><pre class="brush: plain; gutter: false;">
$ gst-launch souphttpsrc location=http://trendnetcam/video.cgi timeout=5 num-buffers=100 ! multipartdemux ! jpegdec ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
[and it waits forever here...]

</pre></p>
<p>To debug, I save some mjpeg frames from the camera.</p>
<p><pre class="brush: plain; gutter: false;">
$ gst-launch souphttpsrc location=http://trendnetcam/video.cgi timeout=5 num-buffers=100 ! filesink location=trendnet.mjpeg
</pre></p>
<p>Searching some more let me <a href="http://permalink.gmane.org/gmane.comp.video.gstreamer.bugs/90152">here</a>, and to the conclusion that the stream that my IP camera is not multipart conform. It has some irregularities that multipartdemux cannot handle.</p>
<p>Mime/multipart is defined in <a href="http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html">RFC1341</a>, and describes how boundaries should be handled. Two things are wrong with my cameras implementation of multipart.</p>
<p>Firstly, the initial boundary does not end with a new line.</p>
<p><pre class="brush: plain; gutter: false;">
$ head trendnet.mjpeg -n 3
--video boundary--Content-length: 58329
Content-type: image/jpeg
</pre></p>
<p>Secondly, all the boundaries are &#8220;end-of-multipart&#8221; boundaries, i.e. they are &#8220;&#8211;video boundary&#8211;&#8221; instead of &#8220;&#8211;video boundary&#8221;.</p>
<p>I don&#8217;t which problem breaks multipartdemux, but the solution was presented in the above forum entry.</p>
<p><pre class="brush: plain; gutter: false;">
$ (echo &quot;--video boundary--&quot;; curl -s http://trendnetcam/video.cgi;) | gst-launch fdsrc do-timestamp=true ! multipartdemux boundary=&quot;video boundary--&quot; ! jpegdec ! autovideosink
</pre></p>
<p>The parts</p>
<ul>
<li>(echo &#8220;&#8211;video boundary&#8211;&#8221;; curl -s http://trendnetcam/video.cgi;): Prepends a boundary line and fetches data from the camera and pipes it to stdout.</li>
<li><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-plugins/html/gstreamer-plugins-fdsrc.html">fdsrc</a> do-timestamp=true: Receives data from stdin. A gstreamer time stamp is added also (this was in the example, so I kept it)</li>
<li><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-multipartdemux.html">multipartdemux</a> boundary=&#8221;video boundary&#8211;&#8221;: Demultiplex the multipart input and use the specified boundary. The trailing &#8220;&#8211;&#8221; is probably the difference between the boundary to use and the auto detected one.</li>
<li>jpegdec ! autovideosink: convert from jpeg to YUV and show on screen.</li>
</ul>
<h1>Mjpeg to theora (take 2)</h1>
<p>Now that the mjpeg stream is correctly handled, we try again.</p>
<p><pre class="brush: plain; gutter: false;">
$ $ (echo &quot;--video boundary--&quot;; curl -s http://trendnetcam/video.cgi;) | gst-launch fdsrc do-timestamp=true ! multipartdemux boundary=&quot;video boundary--&quot; ! jpegdec ! theoraenc ! oggmux !  filesink location=testvideo.ogg
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstFdSrc:fdsrc0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2582): gst_base_src_loop (): /GstPipeline:pipeline0/GstFdSrc:fdsrc0:
streaming task paused, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
</pre></p>
<p>Great, still Internal data flow error. Still non-informative.</p>
<h1>Debugging the pipeline</h1>
<p>gstreamer has some built-in debugging possibilities as described <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/section-checklist-debug.html">here</a>. I use <em>&#8211;gst-debug-level=2</em>, but that might change if my pipeline get big.</p>
<p><pre class="brush: plain; gutter: false; wrap-lines: false;">
$ (echo &quot;--video boundary--&quot;; curl -s http://trendnetcam/video.cgi;) | gst-launch --gst-debug-level=2 fdsrc do-timestamp=true ! multipartdemux boundary=&quot;video boundary--&quot; ! jpegdec ! theoraenc ! oggmux !  filesink location=testvideo.ogg
0:00:00.100388113 12792  0x8233050 WARN               theoraenc gsttheoraenc.c:310:gst_theora_enc_class_init: Failed to determine settings for the speed-level property.
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
0:00:00.910899563 12792  0x837d800 WARN                 basesrc gstbasesrc.c:2582:gst_base_src_loop: error: Internal data flow error.
0:00:00.911039106 12792  0x837d800 WARN                 basesrc gstbasesrc.c:2582:gst_base_src_loop: error: streaming task paused, reason not-negotiated (-4)
ERROR: from element /GstPipeline:pipeline0/GstFdSrc:fdsrc0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2582): gst_base_src_loop (): /GstPipeline:pipeline0/GstFdSrc:fdsrc0:
streaming task paused, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
</pre></p>
<p>Three warnings and two of them converted to errors. Odd, and looking into theoraencs speed-level property doesn&#8217;t tell me much. My guess is that it is frame rate related.</p>
<p>Adding a format specification into the stream</p>
<p><pre class="brush: plain; gutter: false; wrap-lines: false;">
$ (echo &quot;--video boundary--&quot;; curl -s http://trendnetcam/video.cgi;) | gst-launch --gst-debug-level=2 --gst-debug=theora:2 fdsrc do-timestamp=true ! multipartdemux boundary=&quot;video boundary--&quot; ! jpegdec ! video/x-raw-yuv,framerate=4/1 ! theoraenc ! oggmux !  filesink location=nn.ogg
0:00:00.091995704 13004  0x8e6f050 WARN               theoraenc gsttheoraenc.c:310:gst_theora_enc_class_init: Failed to determine settings for the speed-level property.
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
0:00:00.868368027 13004  0x8f9fe98 WARN           basetransform gstbasetransform.c:1211:gst_base_transform_setcaps: transform could not transform video/x-raw-yuv, format=(fourcc)I420, width=(int)640, height=(int)480, framerate=(fraction)0/1 in anything we support
0:00:00.868774364 13004  0x8f9fe98 WARN                 basesrc gstbasesrc.c:2582:gst_base_src_loop: error: Internal data flow error.
0:00:00.868894002 13004  0x8f9fe98 WARN                 basesrc gstbasesrc.c:2582:gst_base_src_loop: error: streaming task paused, reason not-negotiated (-4)
ERROR: from element /GstPipeline:pipeline0/GstFdSrc:fdsrc0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2582): gst_base_src_loop (): /GstPipeline:pipeline0/GstFdSrc:fdsrc0:
streaming task paused, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
</pre></p>
<p>We get at new warning saying that the the capsfilter we just introduced cannot handle the input it is getting. I notice the &#8220;framerate=(fraction)0/1&#8243; part, and conclude that we need something to convert from a framerate of 0 fps to my requested of 4 fps.</p>
<p><pre class="brush: plain; gutter: false;">
$ (echo &quot;--video boundary--&quot;; curl -s http://trendnetcam/video.cgi;) | gst-launch --gst-debug-level=2 fdsrc do-timestamp=true ! multipartdemux boundary=&quot;video boundary--&quot; ! jpegdec ! videorate ! video/x-raw-yuv,framerate=4/1 ! theoraenc ! oggmux !  filesink location=nn.ogg
</pre></p>
<p>The parts</p>
<ul>
<li>(echo &#8220;&#8211;video boundary&#8211;&#8221;; curl -s http://trendnetcam/video.cgi;): get the mjpeg stream</li>
<li>fdsrc do-timestamp=true ! multipartdemux boundary=&#8221;video boundary&#8211;&#8221; ! jpegdec: Receive data, split into images and convert from jpeg</li>
<li><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-videorate.html">videorate</a>: Handles the framerate conversion.</li>
<li>video/x-raw-yuv,framerate=4/1: Caps filter to specify the format to be send to theoraenc</li>
<li>theoraenc ! oggmux ! filesink location=nn.ogg: Convert to theora and save to file</li>
</ul>
<p>And it works.</p>
<h1>Success!</h1>
<p>It took me a while get it all working and I suspect there are still some quirks, but now I can make theora movies that may be shown using HTML5 and video tags. More to come in a future blog post.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moozing.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moozing.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moozing.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moozing.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moozing.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moozing.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moozing.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moozing.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moozing.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moozing.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moozing.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moozing.wordpress.com/411/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moozing.wordpress.com/411/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moozing.wordpress.com/411/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=411&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moozing.wordpress.com/2011/12/28/gstreamer-and-mjpeg/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b26a2570cf4f2ce9d2c3206ebac0a34d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">moozing</media:title>
		</media:content>
	</item>
		<item>
		<title>IP camera, gstreamer and virtual video devices</title>
		<link>http://moozing.wordpress.com/2011/12/26/ip-camera-gstreamer-and-virtual-video-devices/</link>
		<comments>http://moozing.wordpress.com/2011/12/26/ip-camera-gstreamer-and-virtual-video-devices/#comments</comments>
		<pubDate>Mon, 26 Dec 2011 08:00:50 +0000</pubDate>
		<dc:creator>moozing</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Camera]]></category>
		<category><![CDATA[gstreamer]]></category>
		<category><![CDATA[v4l2]]></category>

		<guid isPermaLink="false">http://moozing.wordpress.com/?p=393</guid>
		<description><![CDATA[I have an old IP camera that I want to use for surveillance. First step is to get it into the computer in some usable form. It ended up as a virtual video device using gstreamer. Really cool. The camera It is a Trendnet TV-IP100. Being a couple of year old, it probably is not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=393&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have an old IP camera that I want to use for surveillance. First step is to get it into the computer in some usable form. It ended up as a virtual video device using <a href="http://gstreamer.freedesktop.org/">gstreamer</a>. Really cool.</p>
<p><span id="more-393"></span></p>
<h3>The camera</h3>
<p>It is a<a href="http://www.trendnet.com/products/proddetail.asp?prod=130_TV-IP100&amp;cat=48"> Trendnet TV-IP100</a>. Being a couple of year old, it probably is not the thing to use for professional solutions, but it is capable of sending <a title="mjpg video" href="http://en.wikipedia.org/wiki/Motion_JPEG">mjpg video</a>, and that is what I am going to use.</p>
<p>The usual nmap prodding to see what the device is offering (expand to see detailed output)</p>
<p><pre class="brush: bash; collapse: true; gutter: false; light: false; toolbar: true;">
# nmap -O -T4 trendnetcam -p0-65535 -v

Starting Nmap 5.21 ( http://nmap.org ) at 2011-12-25 19:32 CET
Nmap wishes you a merry Christmas! Specify -sX for Xmas Scan (http://nmap.org/book/man-port-scanning-techniques.html).
Initiating ARP Ping Scan at 19:32
Scanning trendnetcam (192.168.1.154) [1 port]
Completed ARP Ping Scan at 19:32, 0.01s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 19:32
Completed Parallel DNS resolution of 1 host. at 19:32, 0.00s elapsed
Initiating SYN Stealth Scan at 19:32
Scanning trendnetcam (192.168.1.154) [65536 ports]
Discovered open port 80/tcp on 192.168.1.154
Discovered open port 21/tcp on 192.168.1.154
Discovered open port 8465/tcp on 192.168.1.154
Discovered open port 8481/tcp on 192.168.1.154
Completed SYN Stealth Scan at 19:32, 52.19s elapsed (65536 total ports)
Initiating OS detection (try #1) against trendnetcam (192.168.1.154)
Nmap scan report for trendnetcam (192.168.1.154)
Host is up (0.0011s latency).
rDNS record for 192.168.1.154: trendnetcam.lan
Not shown: 65532 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
80/tcp   open  http
8465/tcp open  unknown
8481/tcp open  unknown
MAC Address: 00:14:D1:xx:xx:xx (Trendware International)
Device type: webcam
Running: TRENDnet embedded
OS details: TRENDnet TV-IP100 Internet camera
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=17 (Good luck!)
IP ID Sequence Generation: Incremental

Read data files from: /usr/share/nmap
OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 55.43 seconds
Raw packets sent: 67395 (2.967MB) | Rcvd: 65551 (2.622MB)

</pre></p>
<p>Nmap detect that it is a running the OS &#8220;TRENDnet TV-IP100 Internet camera&#8221;. How cool is that. I thought that if it was that known, <a href="http://metasploit.com">metasploit</a> might have some exploits for it also, but I didn&#8217;t find any. Too bad, that could have been fun.</p>
<p>So we have HTTP running &#8211; I knew that. The ports 8465 and 8481 probably relates to UPnP, which I have no use for currently. The FTP part could be interesting, but not today.</p>
<p>The web interface is so ugly, that I wanted to do some screen shots, but I don&#8217;t have the administrator password. I was going to do a factory reset by pressing the reset button for 5 seconds. That necessitates a paper clip of some sort, which I don&#8217;t currently have. It will just have to get wiped some other time.</p>
<h3></h3>
<h3>Getting video</h3>
<p>gstreamer needs to know where to get the mjpeg stream. The <a href="http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome">motion homepage</a> gives <a href="http://lavrsen.dk/foswiki/bin/view/Motion/TrendNet">the exact urls</a> to use. In our case it is http://trendnetcam/VIDEO.CGI. Btw, motion is a really usable piece of surveillance software (to be installed later).</p>
<p>Testing it as describe in this <a href="http://ipcctvsoft.blogspot.com/2010/07/getting-image-from-mjpeg-source-using_13.html">blog entry</a>.</p>
<p><pre class="brush: bash; gutter: false;">
$ gst-launch -vet souphttpsrc location=http://trendnetcam/video.cgi timeout=5 ! jpegdec ! autovideosink
</pre></p>
<p>It works and opens a windows with the video. I didn&#8217;t find a value for it, but the framerate seemed rather high.</p>
<p>Complete output (should you be interested)</p>
<p><pre class="brush: bash; collapse: true; gutter: false; light: false; toolbar: true;">
$ gst-launch -vet souphttpsrc location=http://trendnetcam/video.cgi timeout=5 ! jpegdec ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstJpegDec:jpegdec0.GstPad:src: caps = video/x-raw-yuv, format=(fourcc)I420, width=(int)640, height=(int)480, framerate=(fraction)0/1
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstXvImageSink:autovideosink0-actual-sink-xvimage.GstPad:sink: caps = video/x-raw-yuv, format=(fourcc)I420, width=(int)640, height=(int)480, framerate=(fraction)0/1
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink: caps = video/x-raw-yuv, format=(fourcc)I420, width=(int)640, height=(int)480, framerate=(fraction)0/1
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink.GstProxyPad:proxypad0: caps = video/x-raw-yuv, format=(fourcc)I420, width=(int)640, height=(int)480, framerate=(fraction)0/1
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
^CCaught interrupt -- handling interrupt.
Interrupt: Stopping pipeline ...
EOS on shutdown enabled -- Forcing EOS on the pipeline
Waiting for EOS...
Got EOS from element &quot;pipeline0&quot;.
EOS received - stopping pipeline...
Execution ended after 3540986465 ns.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstXvImageSink:autovideosink0-actual-sink-xvimage.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink: caps = NULL
/GstPipeline:pipeline0/GstJpegDec:jpegdec0.GstPad:src: caps = NULL
Setting pipeline to NULL ...
Freeing pipeline ...

</pre></p>
<p>Gstreamer works with pipelines. The command issued is about a source <em>souphttpsrc</em>, is decoded using some jpeg filter <em>jpegdec</em>, and finally show using the default graphical sink <em>autovideosink</em>.</p>
<p>Gstreamer quickly gets difficult, and I will look into how to do it using python instead of the command line.</p>
<h3>Virtual camera device</h3>
<p>I located <a href="http://amanick.blogspot.com/2011/02/virtual-webcam-for-skype-linux.html">this blog entry</a> which describe how to get your streams shown in skype or other v4l/<a href="http://en.wikipedia.org/wiki/Video4Linux">v4l2</a> only programs.</p>
<p>It requires the v4l2loopback device. This is a kernel modules that is not part of the mainstream kernels, so we need to complie it ourselves. Luckily, it is included in debian and uses the DKMS framework (which is really cool also).</p>
<p>With some hints from <a href="http://typethinker.blogspot.com/2010/02/ubuntu-fails-to-load-nvidia-kernel.html">this blog</a>, I succeeded in compiling and installing the module using these commands</p>
<p><pre class="brush: bash; gutter: false;">

$ apt-get install v4l2loopback-dkms
$ apt-get install linux-headers-3.1.0-1-686-pae
$ dpkg-reconfigure v4l2loopback-dkms
$ modprobe -v v4l2loopback

</pre></p>
<p>This gives me a v4l2 loopback device on /dev/video1, since my regular built-in USB camera is on /dev/video0.</p>
<p>Testing it with gstreamers built-in test signal</p>
<p><pre class="brush: bash; gutter: false;">

gst-launch -v videotestsrc ! navigationtest ! v4l2sink

</pre></p>
<p>Using<a href="http://projects.gnome.org/cheese/"> cheese</a>,  I am able to see the test signal. Why cheese? It is the one that is installed by default, and gives easy access to the v4l2 devices.</p>
<p>And to see the live mjpeg stream from the IP camera run this</p>
<p><pre class="brush: bash; gutter: false;">
gst-launch -vet  souphttpsrc location=http://trendnetcam/video.cgi timeout=5 ! jpegdec ! v4l2sink
</pre></p>
<p>In summary, going through the above gives me access to the mjpeg stream of my IP camera. It should be the same for other cameras as long as you are able to locate the correct URL.</p>
<p>When no programs are using the device, gst-launch uses 10% CPU power. It could be nice with an on-demand solution, but this is going to run on a server with motion detection running, so it might not be important.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moozing.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moozing.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moozing.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moozing.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moozing.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moozing.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moozing.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moozing.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moozing.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moozing.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moozing.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moozing.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moozing.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moozing.wordpress.com/393/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=393&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moozing.wordpress.com/2011/12/26/ip-camera-gstreamer-and-virtual-video-devices/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b26a2570cf4f2ce9d2c3206ebac0a34d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">moozing</media:title>
		</media:content>
	</item>
		<item>
		<title>A new toy: Logitech presenter R400</title>
		<link>http://moozing.wordpress.com/2011/11/23/a-new-toy-logitech-presenter-r400/</link>
		<comments>http://moozing.wordpress.com/2011/11/23/a-new-toy-logitech-presenter-r400/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 08:00:40 +0000</pubDate>
		<dc:creator>moozing</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[HID]]></category>
		<category><![CDATA[Presenter]]></category>

		<guid isPermaLink="false">http://moozing.wordpress.com/?p=375</guid>
		<description><![CDATA[I also got 2Gb of RAM for an old computer, but that doesn&#8217;t count as &#8220;toys&#8221;. The full name is Logitech wireless Presenter R400. It a  basic four button presenting device with a a built-in laser pointer. Plugging it in The first is to check the syslog So it is not an MTP device. Surprise. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=375&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I also got 2Gb of RAM for an old computer, but that doesn&#8217;t count as &#8220;toys&#8221;.</p>
<p><span id="more-375"></span></p>
<p>The full name is<a href="http://www.logitech.com/mice-pointers/presentation-remote/devices/5993"> Logitech wireless Presenter R400</a>. It a  basic four button presenting device with a a built-in laser pointer.</p>
<h3>Plugging it in</h3>
<p>The first is to check the syslog</p>
<p><pre class="brush: plain; gutter: false; wrap-lines: false;">
$ cat /var/log/syslog
...
Nov 22 19:14:39 leon kernel: [14908.136171] usb 4-1: new low speed USB device number 3 using uhci_hcd
Nov 22 19:14:39 leon kernel: [14908.314200] usb 4-1: New USB device found, idVendor=046d, idProduct=c52d
Nov 22 19:14:39 leon kernel: [14908.314221] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Nov 22 19:14:39 leon kernel: [14908.314235] usb 4-1: Product: USB Receiver
Nov 22 19:14:39 leon kernel: [14908.314246] usb 4-1: Manufacturer: Logitech
Nov 22 19:14:39 leon mtp-probe: checking bus 4, device 3: &quot;/sys/devices/pci0000:00/0000:00:1d.2/usb4/4-1&quot;
Nov 22 19:14:39 leon kernel: [14908.363591] input: Logitech USB Receiver as /devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.0/input/input21
Nov 22 19:14:39 leon kernel: [14908.366591] generic-usb 0003:046D:C52D.0006: input,hiddev0,hidraw2: USB HID v1.11 Keyboard [Logitech USB Receiver] on usb-0000:00:1d.2-1/input0
Nov 22 19:14:39 leon kernel: [14908.397349] input: Logitech USB Receiver as /devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.1/input/input22
Nov 22 19:14:39 leon kernel: [14908.401391] generic-usb 0003:046D:C52D.0007: input,hiddev0,hidraw3: USB HID v1.11 Mouse [Logitech USB Receiver] on usb-0000:00:1d.2-1/input1
Nov 22 19:14:39 leon mtp-probe: bus: 4, device: 3 was not an MTP device
</pre></p>
<p>So it is not an <a href="http://http://en.wikipedia.org/wiki/Media_Transfer_Protocol">MTP device</a>. Surprise.</p>
<p>And the device is recognized as a logitech USB receiver and enabled as two input devices. I&#8217;ll put it on the to-be-checked list to look into why that is.</p>
<p>A quick lsusb, gives us a more readable output.</p>
<p><pre class="brush: plain; gutter: false; wrap-lines: false;">
$ lsusb
...
Bus 004 Device 003: ID 046d:c52d Logitech, Inc.
</pre></p>
<p>We use this to get the detailed information (it is collapsed since it is a long list).</p>
<p><pre class="brush: plain; collapse: true; gutter: false; highlight: [28,37,67]; light: false; toolbar: true; wrap-lines: false;">
# lsusb -d 046d:c52d -v
Bus 004 Device 003: ID 046d:c52d Logitech, Inc.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x046d Logitech, Inc.
  idProduct          0xc52d
  bcdDevice           17.01
  iManufacturer           1 Logitech
  iProduct                2 USB Receiver
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           59
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          4 RQR17.01_B0014
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower               98mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      1 Keyboard
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     187
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     157
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
Device Status:     0x0000
  (Bus Powered)

</pre></p>
<p>That solved the question of the two HID devices from the syslog. As seen in the higlighted lines, it is both a keyboard and a mouse.</p>
<p>I also see that it takes a maximum of 98 mW of power. That is enough for an average laptop user to notice it, but for some reason I don&#8217;t get current power estimates from <a href="http://www.lesswatts.org/projects/powertop/">powerTOP</a>.</p>
<h3>X events</h3>
<p>I run the xev command. It is simple and it works. I ought to find a more informative utility for checking my HID.</p>
<p><pre class="brush: plain; collapse: true; gutter: false; highlight: [28,37,67]; light: false; toolbar: true; wrap-lines: false;">
$ xev

...

KeyPress event, serial 34, synthetic NO, window 0x5e00001,
root 0xab, subw 0x0, time 17999665, (490,320), root:(2361,624),
state 0x0, keycode 112 (keysym 0xff55, Prior), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

KeyRelease event, serial 34, synthetic NO, window 0x5e00001,
root 0xab, subw 0x0, time 17999833, (490,320), root:(2361,624),
state 0x0, keycode 112 (keysym 0xff55, Prior), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False

KeyPress event, serial 34, synthetic NO, window 0x5e00001,
root 0xab, subw 0x0, time 18001395, (490,320), root:(2361,624),
state 0x0, keycode 117 (keysym 0xff56, Next), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

KeyRelease event, serial 34, synthetic NO, window 0x5e00001,
root 0xab, subw 0x0, time 18001569, (490,320), root:(2361,624),
state 0x0, keycode 117 (keysym 0xff56, Next), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False

...

KeyPress event, serial 34, synthetic NO, window 0x5e00001,
root 0xab, subw 0x0, time 18091665, (-283,47), root:(1588,351),
state 0x0, keycode 71 (keysym 0xffc2, F5), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

KeyRelease event, serial 34, synthetic NO, window 0x5e00001,
root 0xab, subw 0x0, time 18091769, (-283,47), root:(1588,351),
state 0x0, keycode 71 (keysym 0xffc2, F5), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False

KeyPress event, serial 34, synthetic NO, window 0x5e00001,
root 0xab, subw 0x0, time 18092042, (-283,47), root:(1588,351),
state 0x0, keycode 9 (keysym 0xff1b, Escape), same_screen YES,
XLookupString gives 1 bytes: (1b) &quot; &quot;
XmbLookupString gives 1 bytes: (1b) &quot; &quot;
XFilterEvent returns: False

KeyRelease event, serial 34, synthetic NO, window 0x5e00001,
root 0xab, subw 0x0, time 18092153, (-283,47), root:(1588,351),
state 0x0, keycode 9 (keysym 0xff1b, Escape), same_screen YES,
XLookupString gives 1 bytes: (1b) &quot; &quot;
XFilterEvent returns: False

KeyPress event, serial 34, synthetic NO, window 0x5e00001,
root 0xab, subw 0x0, time 18104777, (-322,446), root:(1549,750),
state 0x0, keycode 60 (keysym 0x2e, period), same_screen YES,
XLookupString gives 1 bytes: (2e) &quot;.&quot;
XmbLookupString gives 1 bytes: (2e) &quot;.&quot;
XFilterEvent returns: False

KeyRelease event, serial 34, synthetic NO, window 0x5e00001,
root 0xab, subw 0x0, time 18104953, (-322,446), root:(1549,750),
state 0x0, keycode 60 (keysym 0x2e, period), same_screen YES,
XLookupString gives 1 bytes: (2e) &quot;.&quot;
XFilterEvent returns: False
...
</pre></p>
<p>All four buttons corresponds to keyborad press and release events. The first two are page-up and page-down. The third one is toggling between F5 and ESC. The last one is period.</p>
<p>I don&#8217;t seem to be able to make send me mouse events.Still not surprised.</p>
<h3>Testing it</h3>
<p>It just works. Plug it in, start LibreOffice Impress and start using it. The toggling makes sense since F5 is start presentation and ESC is to stop it. It also works in Evince with PDF files.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moozing.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moozing.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moozing.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moozing.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moozing.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moozing.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moozing.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moozing.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moozing.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moozing.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moozing.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moozing.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moozing.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moozing.wordpress.com/375/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=375&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moozing.wordpress.com/2011/11/23/a-new-toy-logitech-presenter-r400/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b26a2570cf4f2ce9d2c3206ebac0a34d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">moozing</media:title>
		</media:content>
	</item>
		<item>
		<title>Making ideas happen</title>
		<link>http://moozing.wordpress.com/2011/11/07/making-idea-happen/</link>
		<comments>http://moozing.wordpress.com/2011/11/07/making-idea-happen/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 08:00:19 +0000</pubDate>
		<dc:creator>moozing</dc:creator>
				<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://moozing.wordpress.com/?p=371</guid>
		<description><![CDATA[It is a book by Scott Belsky (Amazon link). I dont remember how I located the book, but I am glad I did. It was a good read. It is all about how to make all those wonderful ideas that most of us get on a daily basis and turn them into something. Since one [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=371&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It is a book by Scott Belsky (<a href="http://www.amazon.co.uk/Making-Ideas-Happen-Overcoming-Obstacles/dp/0670920606/ref=sr_1_3?ie=UTF8&amp;qid=1320606002&amp;sr=8-3">Amazon link</a>). I dont remember how I located the book, but I am glad I did. It was a good read.</p>
<p>It is all about how to make all those wonderful ideas that most of us get on a daily basis and turn them into something. Since one of his advises is to &#8220;kill idea liberally&#8221;, most ideas should be buried &#8211; I tend to agree. Not killing ideas will make you have to much to do and no focus.</p>
<p>He introduces something he calls &#8220;the action method&#8221;. I like it, since that was I have started doing a couple of years ago, so I think he is right. It is all about making progress. Stuff that is to be done is to be decomposed into actionable items, and each item must have a person associated to it. I am considering making that chapter mandatory reading for my students. They tend to be all tech and no focus.</p>
<p>The way I handle it is to have a Todo lists in <a href="http://zim-wiki.org/">Zim</a>. The lists are themed based on which page they are on, and sometimes I add specific tags to the todo-item. Zim then takes the lot a makes med a sortable list of stuff to do. It works. It is simple. Just try it.</p>
<p>Another thing that I recognized is his concept of backburner. It is basically the same as a SCRUM backlog. What to do when you have more tasks that is possible to solve? You prioritize and the stuff you don&#8217;t do now, put them on a list for some later time (and review that list a given intervals).</p>
<p>He continues to discuss the importance of working with other people. A key point is the three personality types: the dreamer, the doer and the incrementalist. The first two we all know. It is the person with a lot of ideas and no implementations, and the person who is all implementation and no ideas. They are equally good/bad. The important part is to know which kind the person is. The last one, &#8220;the incrementalist&#8221;, is a person capable of both, and is a dreamer when required and a doer when need be. They apparently have a tendency of doing too many things at ones.</p>
<p>He has a lot more interesting points, and the book is definitely worth the read. Most people I know, would benefit from some of his advice.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moozing.wordpress.com/371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moozing.wordpress.com/371/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moozing.wordpress.com/371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moozing.wordpress.com/371/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moozing.wordpress.com/371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moozing.wordpress.com/371/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moozing.wordpress.com/371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moozing.wordpress.com/371/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moozing.wordpress.com/371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moozing.wordpress.com/371/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moozing.wordpress.com/371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moozing.wordpress.com/371/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moozing.wordpress.com/371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moozing.wordpress.com/371/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=371&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moozing.wordpress.com/2011/11/07/making-idea-happen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b26a2570cf4f2ce9d2c3206ebac0a34d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">moozing</media:title>
		</media:content>
	</item>
		<item>
		<title>Browsing with a Wii remote</title>
		<link>http://moozing.wordpress.com/2011/05/16/browsing-with-a-wii-remote/</link>
		<comments>http://moozing.wordpress.com/2011/05/16/browsing-with-a-wii-remote/#comments</comments>
		<pubDate>Mon, 16 May 2011 07:00:00 +0000</pubDate>
		<dc:creator>moozing</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://moozing.wordpress.com/?p=364</guid>
		<description><![CDATA[It would be cool to use a Wii remote for browsing. Having a some sort of media PC connected to the TV and using the Wii remote as pointing device could be cool. I found the homebrew channel, but they are about running stuff on a Wii. They even have Linux running on the Wii. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=364&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It would be cool to use a Wii remote for browsing. Having a some sort of media PC connected to the TV and using the Wii remote as pointing device could be cool.</p>
<p>I found <a href="http://wiibrew.org/">the homebrew channel</a>, but they are about running stuff on a Wii. They even have <a href="http://www.youtube.com/watch?v=1oPdRIagtFE">Linux</a> running on the Wii.</p>
<p>The Wii remote connects to the hardware using bluetooth. The sensor bar is actually &#8220;just&#8221; a couple of IR diodes that is detected by the Wii remote. <a href="http://www.youtube.com/watch?v=Jd3-eiid-Uw">Here</a> is a cool use for it.</p>
<p>Next was <a href="http://www.youtube.com/watch?v=Wu0THVy1e7A">this video</a>, so apparently I am not the only one who think that the Wii remote is a cool HID. <a href="http://www.mattcutts.com/blog/linux-wiimote-via-bluetooth/">This blog entry</a> tells how to get the bluetooth part of the Wii remote to interface with Ubuntu.</p>
<p>As mentioned above, the sensor bar is just some diodes. <a href="http://e.inste.in/2007/04/13/building-a-wiimote-usb-sensor-bar/">Here</a> is a description of how to make a sensor bar and power it from USB.</p>
<p>In conclusion, the software is out there and I just need to find the time to implement it. I have doubts as to the precision of the remote. If it is to be used for browsing, think some sort of snap-to-link must be implemented.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moozing.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moozing.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moozing.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moozing.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moozing.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moozing.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moozing.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moozing.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moozing.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moozing.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moozing.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moozing.wordpress.com/364/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moozing.wordpress.com/364/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moozing.wordpress.com/364/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=364&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moozing.wordpress.com/2011/05/16/browsing-with-a-wii-remote/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b26a2570cf4f2ce9d2c3206ebac0a34d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">moozing</media:title>
		</media:content>
	</item>
		<item>
		<title>Testing Rackspace</title>
		<link>http://moozing.wordpress.com/2011/05/15/testing-rackspace/</link>
		<comments>http://moozing.wordpress.com/2011/05/15/testing-rackspace/#comments</comments>
		<pubDate>Sun, 15 May 2011 07:00:28 +0000</pubDate>
		<dc:creator>moozing</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Linux installation]]></category>
		<category><![CDATA[Rackspace]]></category>

		<guid isPermaLink="false">http://moozing.wordpress.com/?p=360</guid>
		<description><![CDATA[I have decided that it was time to try how this cloud stuff works. After searching a bit, I found rackspace.com and decided that having a server in the cloud for $10 per month was cheap enough to look into. I am considering whether or not I want to have my own server at home. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=360&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have decided that it was time to try how this cloud stuff works. After searching a bit, I found<a title="rackspace" href="http://rackspace.com/cloud"> rackspace.com</a> and decided that having a server in the cloud for $10 per month was cheap enough to look into. I am considering whether or not I want to have my own server at home.</p>
<p><span id="more-360"></span></p>
<h3>First thoughts</h3>
<p>The sign up was easy. They call you back to verify your credit card information, and that was a bit odd. There must be some legal issue or a lot of credit card fraud for them to insist on calling people back.</p>
<p>Once the account has been created and activated, it is easy to use. You receive an email with the relevant links. I have worked with virtualization software like <a href="http://vmware.com">vmware</a> and <a href="http://virtualbox.org">virtualbox</a>, so I searched for the start/stop button. It doesn&#8217;t work that way. The cloud concepts take a little getting used to &#8211; it is not the same as virtualization@home. Don&#8217;t issue a &#8216;halt&#8217; on the command line&#8230;</p>
<p>An example; when starting a server, you get to chose between some standard servers &#8211; that is fine, except that that you have to use cloud files (at $0.15/month/Gb) if you want to stop it and resume later. I did not test it, but it seems that you must make a backup of the running machine in order to make changes persistent. On the other hand, when you have an image, you may roll out as many instances as you like. I don&#8217;t have a use for it right now, but maybe at a later time.</p>
<h3>Using it</h3>
<p>The standard server allows for ssh, and you get an email with the IP address and the root password. It is easy and I had the machine up-and-running in no time and was able to slogin to it.</p>
<p>The Linux system reported itself as a quad core AMD processor with 256 Mb of memory and 10 Gb of disk space. This is the smallest machine available.</p>
<p>It got really interesting when I did a speed test of the hard disk (using hdparm -Tt). It reported 3 Gb/s for cached read and 270 Mb/s for buffered disk reads. This is four to six times faster than my Ideapad S12. So I decided on testing it.</p>
<p>Compiling kernel 2.6.38 on my laptop takes 124 minutes. It is boring, it takes forever, and it mostly blocks normal use while it compiles/links. So that was a good candidate for work to be done in the cloud.</p>
<p>The steps.</p>
<ol>
<li>Start server</li>
<li>Login</li>
<li>Install necessary packages</li>
<li>Create a new user (not essential, but best practice)</li>
<li>Download and unpack the kernel sources</li>
<li>Upload .config file</li>
<li><em>make oldconfig</em> or <em>make menuconfig</em></li>
<li><em>make dep-pkg</em></li>
<li>Download the packages</li>
<li>Shut down server</li>
</ol>
<p>It took 40 minutes from start to finish. And I could probably shave some minutes off that time by automating the process. It is definitely a viable solution for high I/O work like kernel compilations. The kernel compilation part took around 15 minutes.</p>
<p>A small disclaimer. Something went wrong with the packages, and I ended up with packages for the AMD64 architecture. I did something wrong with the packages I installed, and stuff got auto detected.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moozing.wordpress.com/360/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moozing.wordpress.com/360/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moozing.wordpress.com/360/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moozing.wordpress.com/360/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moozing.wordpress.com/360/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moozing.wordpress.com/360/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moozing.wordpress.com/360/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moozing.wordpress.com/360/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moozing.wordpress.com/360/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moozing.wordpress.com/360/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moozing.wordpress.com/360/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moozing.wordpress.com/360/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moozing.wordpress.com/360/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moozing.wordpress.com/360/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=360&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moozing.wordpress.com/2011/05/15/testing-rackspace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b26a2570cf4f2ce9d2c3206ebac0a34d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">moozing</media:title>
		</media:content>
	</item>
		<item>
		<title>Cross compile in Debian</title>
		<link>http://moozing.wordpress.com/2011/04/05/cross-compile-in-debian/</link>
		<comments>http://moozing.wordpress.com/2011/04/05/cross-compile-in-debian/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 07:00:37 +0000</pubDate>
		<dc:creator>moozing</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Cross compile]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Emdebian]]></category>

		<guid isPermaLink="false">http://moozing.wordpress.com/?p=343</guid>
		<description><![CDATA[As mentioned earlier, I have a new wireless router and I decided that the time was right to do some cross compilation. Cross compilation is the act of compiling a program on one kind of computer (the host) and using the binaries on a different machine with a different architecture (the target). It has the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=343&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As mentioned <a title="OpenWrt and Linksys WRT160NL" href="http://moozing.wordpress.com/2011/03/19/336/">earlier</a>, I have a new wireless router and I decided that the time was right to do some cross compilation.<span id="more-343"></span></p>
<p>Cross compilation is the act of compiling a program on one kind of computer (the host) and using the binaries on a different machine with a different architecture (the target). It has the big advantage, that the host may have a lot of processing power, RAM and temporary disk space while the target may be very small (like a router or other embedded device).</p>
<p>I was told to &#8220;just add -march=xxx to gcc and it should work..&#8221;. It turned out to be untrue, hence this blog post.</p>
<h3>The host</h3>
<p>The host system runs a standard Debian Squeeze installation. Cpuinfo looks like this:</p>
<p><pre class="brush: bash; gutter: false;"> # cat /proc/cpuinfo
processor    : 0
vendor_id    : GenuineIntel
cpu family    : 15
model        : 2
model name    : Intel(R) Pentium(R) 4 CPU 2.80GHz
stepping    : 9
cpu MHz        : 2798.650
[snip]
</pre></p>
<p>It is a 2.8 GHz intel processor (on both processors), SATA disks and 3 Gb of memory.</p>
<h3>Target</h3>
<p>Target is my Linksys Wrt160nl wireless router.</p>
<p><pre class="brush: bash; gutter: false;"># cat /proc/cpuinfo
system type        : Atheros AR9130 rev 2
machine            : Linksys WRT160NL
processor        : 0
cpu model        : MIPS 24Kc V7.4
BogoMIPS        : 266.24
wait instruction    : yes
microsecond timers    : yes
tlb_entries        : 16
extra interrupt vector    : yes
hardware watchpoint    : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
ASEs implemented    : mips16
shadow register sets    : 1
core            : 0
VCED exceptions        : not available
VCEI exceptions        : not available
</pre></p>
<p>The target is a Mips 24kc with 30 Mb of RAM and something like 8 Mb of flash. Converting from BogoMIPS to Mhz is not trivial, but <a href="http://www.ivoidwarranties.com/2011/03/linksys-wrt160nl-and-dd-wrt.html">here</a> it is reported as being a 400 Mhz processor.</p>
<p>I am surprised of how different the cpuinfo information is on the two systems. It seems that the information is highly dependant on the architecture &#8211; &#8220;stepping&#8221; is apparently not a concept used for mips.</p>
<p>Anyway, it should be obvious why I want to do cross compilation.</p>
<h3>Configuring the host</h3>
<p>The first thing to check is the gcc compiler.</p>
<p><pre class="brush: bash; gutter: false;"># gcc -dumpmachine
i486-linux-gnu
</pre></p>
<p>This tells us why the &#8220;-march&#8221; thing is not working. Gcc on my standard Debian Squeeze is able to build for intel architechtures only. It makes sense to only be able to build for the curren host architechture. Cross compilation is not that common.</p>
<p>To do cross compilation the Debian way, we use <a href="http://www.emdebian.org/">emdebian</a>. They have made cross compilation toolchains. I started following <a href="http://www.emdebian.org/tools/crossdev.html">this page</a>. It turned out to be a bad idea, but it gave me some pointers. The &#8220;problem&#8221; is that they are working hard on making an easy system for handling cross compilation. Currently <a href="http://packages.debian.org/search?keywords=apt-cross">apt-cross</a> is out as of Squeeze and<a href="http://dpkg-cross.alioth.debian.org/"> dpkg-cross</a> are to be used for now, but (as I understand it) they are being phased out and merged with apr, xapt and dpkg.</p>
<p>We need to add emdebian to sources.list</p>
<p><pre class="brush: bash; gutter: false;">deb http://www.emdebian.org/debian/ squeeze main
apt-get update
apt-get install emdebian-archive-keyring
</pre></p>
<p>The nice people at emdebian.org has made a complete mips toolchain. Adapting from here, I install the packages</p>
<p><pre class="brush: bash; gutter: false;"># apt-get install linux-libc-dev-mips-cross libc6-mips-cross libc6-dev-mips-cross binutils-mips-linux-gnu gcc-4.4-mips-linux-gnu g++-4.4-mips-linux-gnu
</pre></p>
<p>This install the gcc compiler and some support libraries.</p>
<p><pre class="brush: bash; gutter: false;"># mips-linux-gnu-gcc -dumpmachine
mips-linux-gnu
</pre></p>
<p>I now have a gcc compiler that is able to compile for the mips platform. Next step is to make a &#8220;Hello world&#8221; program, build it and copy it to the router to test the cross compilation for real.</p>
<h3>Hello world</h3>
<p>I start <a href="http://en.wikipedia.org/wiki/Hello_world_program_examples#C">here </a>for the hello world program.</p>
<p><pre class="brush: bash; gutter: false;">me@host:~$ gcc hallo.c
me@host:~$ ./a.out
Hello world
</pre></p>
<p>Now for the cross compilation</p>
<p><pre class="brush: bash; gutter: false;">
me@host:~$ mips-linux-gnu-gcc hallo.c
me@host:~$ ./a.out
-bash: ./a.out: cannot execute binary file
me@host:~$ scp a.out root@192.168.2.1:/tmp/
a.out                                         100% 5741     5.6KB/s   00:00
me@host:~$slogin root@192.168.2.1

BusyBox v1.15.3 (2010-07-10 11:43:31 PDT) built-in shell (ash)
Enter 'help' for a list of built-in commands.

 _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
 |__| W I R E L E S S   F R E E D O M
 Backfire (10.03.1-rc3, r22796) --------------------
 * 1/3 shot Kahlua    In a shot glass, layer Kahlua
 * 1/3 shot Bailey's  on the bottom, then Bailey's,
 * 1/3 shot Vodka     then Vodka.
 ---------------------------------------------------
root@Target:~# /tmp/a.out
-ash: /tmp/a.out: not found
</pre></p>
<p>First the compilation succeeded and the resulting binary was not runable on the intel machine. Next I copied the binary to the Linksys router, and tried to execute it. It failed.</p>
<p>The &#8220;not found&#8221; found is related to a shared library that fails to load. Rebuilding with &#8220;-muclibc&#8221; library,</p>
<p><pre class="brush: bash; gutter: false;">&lt;/pre&gt;
me@host:~$ mips-linux-gnu-gcc -muclibc hallo.c
me@host:~$ scp a.out root@192.168.2.1:/tmp/
a.out                                         100% 5757     5.6KB/s   00:00
me@host:~$ slogin root@192.168.2.1

[snip]
root@target:~# /tmp/a.out
/tmp/a.out: can't load library 'libc.so.6'
</pre></p>
<p>The executable runs, except for some sort of issue related to a named shared libraries. I will work on that next time.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moozing.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moozing.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moozing.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moozing.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moozing.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moozing.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moozing.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moozing.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moozing.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moozing.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moozing.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moozing.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moozing.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moozing.wordpress.com/343/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=343&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moozing.wordpress.com/2011/04/05/cross-compile-in-debian/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b26a2570cf4f2ce9d2c3206ebac0a34d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">moozing</media:title>
		</media:content>
	</item>
		<item>
		<title>OpenWrt and Linksys WRT160NL</title>
		<link>http://moozing.wordpress.com/2011/03/19/336/</link>
		<comments>http://moozing.wordpress.com/2011/03/19/336/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 08:00:59 +0000</pubDate>
		<dc:creator>moozing</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[OpenWrt]]></category>
		<category><![CDATA[Wireless]]></category>

		<guid isPermaLink="false">http://moozing.wordpress.com/?p=336</guid>
		<description><![CDATA[My primary router died (and will be dissected later), so I bought a new one. It was a Linksys WRT160NL, and it took me 10 minutes to unwrap it and install OpenWrt. When installing OpenWrt it is all about finding the correct to upload. Before buying it, I googled opernwrt and wrt160nl and got some [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=336&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My primary router died (and will be dissected later), so I bought a new one. It was a Linksys WRT160NL, and it took me 10 minutes to unwrap it and install OpenWrt.</p>
<p><span id="more-336"></span></p>
<p>When installing OpenWrt it is all about finding the correct to upload. Before buying it, I googled<a href="opernwrt and wrt160nl "> opernwrt and wrt160nl </a>and got some hits to convince me that there wasn&#8217;t some big red flags anywhere.</p>
<p>In the <a href="http://wiki.openwrt.org/toh/linksys/wrt160nl">wiki</a>, OpenWrt on WRT160NL is called work in progress and that you have to have access to the serial port. After reading in the <a href="https://forum.openwrt.org/viewtopic.php?id=20298&amp;p=25">forums</a>, I decided that the earlier information was outdated and that it ought to work.</p>
<h4>Quick howto:</h4>
<p>Download the firmware</p>
<p><pre class="brush: bash; gutter: false;">wget http://downloads.openwrt.org/backfire/10.03/ar71xx/openwrt-ar71xx-wrt160nl-jffs2.bin</pre></p>
<p>Use the web interface to install the &#8220;new&#8221; version of the firmware.</p>
<p>Access OpenWrt using the browser on <a href="http://192.168.1.1">http://192.168.1.1</a></p>
<p>It was that simple. Cred to the OpenWrt team.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moozing.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moozing.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moozing.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moozing.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moozing.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moozing.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moozing.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moozing.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moozing.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moozing.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moozing.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moozing.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moozing.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moozing.wordpress.com/336/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=336&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moozing.wordpress.com/2011/03/19/336/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b26a2570cf4f2ce9d2c3206ebac0a34d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">moozing</media:title>
		</media:content>
	</item>
		<item>
		<title>Open source days 2011</title>
		<link>http://moozing.wordpress.com/2011/03/07/open-source-days-2011/</link>
		<comments>http://moozing.wordpress.com/2011/03/07/open-source-days-2011/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 08:00:51 +0000</pubDate>
		<dc:creator>moozing</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Open source days]]></category>

		<guid isPermaLink="false">http://moozing.wordpress.com/?p=332</guid>
		<description><![CDATA[Yesterday, I attended this years Open Source days in Copenhagen. It was my first time at Open source days, and definitely not the last. It was fun to meet and listen to what Open Source people had to say. I had decided to follow community track, since that is my primary area of interest these [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=332&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I attended this years Open Source days in Copenhagen. It was my first time at Open source days, and definitely not the last. It was fun to meet and listen to what Open Source people had to say. <span id="more-332"></span>I had decided to follow community track, since that is my primary area of interest these days. Maybe these open soucers had some brilliant idea of how I may use their community experiences to motivate my students. That would be interesting indeed.</p>
<p>More information on Open Source days, may be found on their <a href="http://www.opensourcedays.org/">homepage</a>. Everywhere people were mentioning twitter and Facebook &#8211; it might be relevant if I want to do community stuff.</p>
<p>The opening keynote speaker was Colin Percival, who was talking about his efforts in making FreeBSD run on Amazon EC2. Since I use neither FreeBSD nor Amazon EC2, it was fairly off-topic for me, but it reminded me of clouds. It is something that we need to get into with the student. There was talks on clouds, but I didn&#8217;t hear them since I followed the community track. I found his blog <a href="http://www.daemonology.net/blog/">here</a> and <a href="http://twitter.com/cperciva">twitter</a>.</p>
<p>Next was Noirin Shirley with a talk on how open source saves the world. It is a big title. I always enjoy hearing people talk about stuff they really really find to be cool. It was obvious from the start that she thinks that Open Source and crowdsourcing are the way to go. She spoke of the <a href="http://ushahidi.com/">ushahidi</a> project and its use in disaster management it appears to be a project worth a link. I found her blog <a href="http://blog.nerdchic.net/">here</a> and <a href="http://twitter.com/noirins">twitter</a>.</p>
<p>Ryan Ozimek was next with a talk on how it works a <a href="http://www.joomla.org/">Joomla</a>. He is an energetic american, who suffered a bit from jet lag. Anyway, it was interesting to hear about the bumps on the road for Joomla. There was a point when he started mentioning &#8220;mission&#8221;, &#8220;vision&#8221; and &#8220;value&#8221;, that I thought I was in a bad dream &#8211; we are going through that at my school, and it is boring, abstract and utterly not useful for me in my daily work. If he is right that they are important concepts for a successful community, I ought to look at it again&#8230;I was unable to find a personal blog, but he is (surprise, surprise) on <a href="http://twitter.com/cozimek">twitter</a>.</p>
<p>From the <a href="http://fedoraproject.org/">fedora project</a> was ambassador Rober Scheck. He talked about the structure of Fedora community and their relationship with<a href="http://www.redhat.com/"> Red hat</a>. Red hat apparently saw that they had to tap into a community of volunteers in order to stay in business. From the outside, it seems like a plausible business model to divide the company into the community part (Fedora) and the business part (red hat enterprise Linux). I found his homepage <a href="http://www.robert-scheck.de/">here</a> (it is in german).</p>
<p>The last of my community track was a talk by Mads Doré of <a href="http://doredevelopment.dk/">DoreDevelopment</a>. He has taken his company into the open source world, and he seems to be enjoying it. In this talk he was focussing on the open source project <a href="http://oe-lite.org">oe-lite</a>. It is a derivative of <a href="http://www.openembedded.org/index.php/Main_Page">open-embedded</a> which I have tried (and failed) to used in an embedded project some years ago. I think that it is relevant for my students to use this, but we have to look at it in greater detail &#8211; like locating the wiki part of the site.</p>
<p>Then I switched to Peter Makholm and a hands-on talk about how to destroy your installation&#8230; His blog is <a href="http://peter.makholm.net/">here</a> and <a href="http://identi.ca/pmakholm">identi.ca</a>.</p>
<p>The closing keynote was a very entertaining talk by Paul Fenwick. It was fun (and not open source related). I located his <a href="http://pjf.id.au/index.html">homepage</a> and <a href="http://twitter.com/pjf">twitter</a>.</p>
<p>Closing thoughts:</p>
<ul>
<li>Most of these people have day jobs and do this work on a voluntary basis without getting paid. I find this to be very cool.</li>
<li>What is the difference between twitter and identi.ca?</li>
<li>I need to look into this community and crowdsourcing thing some more.</li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moozing.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moozing.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moozing.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moozing.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moozing.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moozing.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moozing.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moozing.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moozing.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moozing.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moozing.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moozing.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moozing.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moozing.wordpress.com/332/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moozing.wordpress.com&amp;blog=13960506&amp;post=332&amp;subd=moozing&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moozing.wordpress.com/2011/03/07/open-source-days-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b26a2570cf4f2ce9d2c3206ebac0a34d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">moozing</media:title>
		</media:content>
	</item>
	</channel>
</rss>
