<?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>CoR &#187; Qt4</title>
	<atom:link href="http://blog.cor-net.org/tag/qt4/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cor-net.org</link>
	<description>...</description>
	<lastBuildDate>Sat, 03 Jul 2010 19:52:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>CanArch Project</title>
		<link>http://blog.cor-net.org/embedded/canoe-project/</link>
		<comments>http://blog.cor-net.org/embedded/canoe-project/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 08:22:13 +0000</pubDate>
		<dc:creator>cor</dc:creator>
				<category><![CDATA[Embedded Development]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[can]]></category>
		<category><![CDATA[CanOE]]></category>
		<category><![CDATA[LGPL]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Qt4]]></category>
		<category><![CDATA[sourceforge]]></category>

		<guid isPermaLink="false">http://blog.cor-net.org/?p=41</guid>
		<description><![CDATA[An easy way to manage your CAN network using a C++ OpenSource library.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><em>An easy way to manage your CAN network using a C++ OpenSource library.</em></p>
<p>Last year, I compete with a few teammates in the French Cup of Robotic, and our robot was extensively using CAN, because it&#8217;s a really robust and widespread network in embedded systems (and it&#8217;s true we didn&#8217;t had any trouble with it). The problem I was facing concerned how to manage all those ids and stuff in an efficient way.</p>
<p>I tried to find some solution on the Internet, but didn&#8217;t find any that would answer my problem without making me writing different code for the many few architectures we were using (PIC18F, dsPIC, ARM9 &#8230;).</p>
<p>So I wrote a small app, that used an XML file to &#8220;define&#8221; the network architecture (nodes, frames), that automatically generated IDs (using priority, node id and frame id) and exported them in a C Header using #define.</p>
<p><strong>I rewrote it from scratch, implementing a lot of things that were not possible in the first version and improving the overall architecture.</strong></p>
<p><strong>This is now provided as a library under LGPL, with a few tools to exploit it easily.</strong></p>
<p>So, if you have an existing CAN network, or a new one to design, and if you want to write not too static code for embedded systems, and analyze smartly the live feed of your network, CanArch might be helpful for you.</p>
<h1>Example</h1>
<p>So here is an XML file, it&#8217;s the &#8220;base&#8221;:</p>
<div class="aligncenter bigfileicon"><a href="http://blog.cor-net.org/wp-content/uploads/2009/08/simple.xml"><img src="http://blog.cor-net.org/wp-content/plugins/bigfiles/icons/32x32/application-xml.png" alt="simple.xml" /><br /><span>simple.xml</span></a></div>
<p>There is two parts:</p>
<ul>
<li>Configuration (conf): Network name, bitrate, types definition and id generation infos</li>
<li>Network tree (network): The network is a tree with <em>nodes</em> (devices on the network) which have <em>frames</em></li>
</ul>
<p>Hu ? Yeah, in that file you specify the nodes on your network, and the kind of frames that each node can emit.</p>
<p>Then the <em>format</em> of each frame is specified, using <em>types</em> like <em>int</em> or <em>enum</em>, with a bit size that you can specify.</p>
<p>Then you can generate IDs using the policy you specified in the definition file, and you can export it as a C Header like this one:</p>
<div class="aligncenter bigfileicon"><a href="http://blog.cor-net.org/wp-content/uploads/2009/08/graph.h"><img src="http://blog.cor-net.org/wp-content/plugins/bigfiles/icons/32x32/text-x-chdr.png" alt="graph.h" /><br /><span>graph.h</span></a></div>
<p>(well this is actually an export of <a href="http://blog.cor-net.org/wp-content/uploads/2009/08/graph.xml">that (graph.xml)</a> definition file, which is more complex than the simple previous one)</p>
<p>And to handle all the import / export / visualization, there is a nice Qt4 app called NetworkView:</p>
<div id="attachment_46" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.cor-net.org/wp-content/uploads/2009/08/Screenshot-NetworkView.png" rel="wp-prettyPhoto[g41]"><img class="size-medium wp-image-46" title="NetworkView" src="http://blog.cor-net.org/wp-content/uploads/2009/08/Screenshot-NetworkView-300x225.png" alt="Qt4 NetworkView Gui" width="300" height="225" /></a><p class="wp-caption-text">NetworkView : a Qt4 CanArch Gui</p></div>
<h1>Developers</h1>
<p>This project is fairly new, if you think you can help, I would be really glad if you do, so please contact me so we can talk about that.</p>
<p>There are lot of things that can be developed to improve this project, I&#8217;m thinking about a clean way to handle existing frames and interfaces (using <a href="http://developer.berlios.de/projects/socketcan/">socketcan</a> on Linux for example).</p>
<p>Also, a better support for existing networks, and DeviceNet and other higher level networks based on CAN are ideas I&#8217;m thinking about, and I would be glad to share the work, cause I won&#8217;t be able to do all that while studying and with my internship coming this winter.</p>
<h1>Download / Source</h1>
<p>The project page on BitBucket is <a href="http://bitbucket.org/corfr/canarch/">http://bitbucket.org/corfr/canarch/</a>, you can download the sources from there.</p>
<p><strong><br />
EDIT: CanArch has been renamed from CanOE, since this is a trademark for the <a href="http://www.vector.com/vi_canoe_en.html">Vector CANoe</a> software.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cor-net.org/embedded/canoe-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Qt 4.5 on mini2440</title>
		<link>http://blog.cor-net.org/embedded/mini2440/qt-45-on-mini2440/</link>
		<comments>http://blog.cor-net.org/embedded/mini2440/qt-45-on-mini2440/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 03:17:49 +0000</pubDate>
		<dc:creator>cor</dc:creator>
				<category><![CDATA[Mini2440]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Qt4]]></category>
		<category><![CDATA[touchscreen]]></category>

		<guid isPermaLink="false">http://blog.cor-net.org/?p=15</guid>
		<description><![CDATA[A quick HowTo about the setup of Qt4 and touchscreen on the Mini2440 development board.]]></description>
			<content:encoded><![CDATA[<p>Well, you didn&#8217;t bought this fresh mini2440 with a 3,5&#8243; or 7&#8243; touchscreen just for putting another dust receiver on your desk didn&#8217;t you ?</p>
<h1>Framebuffer</h1>
<p>If you compiled a kernel from the mini2440 kernel repository with the mini2440_defconfig, the framebuffer driver is loaded by default. You should see an &#8220;Armwork&#8221; logo when booting your board. If it&#8217;s not the case and you have a 7&#8243; screen, you have to pass &#8220;mini2440=1tb&#8221; as a boot argument for the kernel ( 0 is for 320&#215;240, 1 for 800&#215;480 ). This has to be done in u-boot.</p>
<p>The framebuffer for the screen should be avaiable on device /dev/fb0, if that entry does not exist, you probably want to make it by using the following command &#8220;mknod /dev/fb0 c 29 0&#8243;. If you wonder why those numbers, well, the major &#8220;29&#8243; is from the /proc/devices file, there you can see that the major 29 is reserved for fb character devices, and as there is only one fb on the system, the minor is 0, but if you want to make sure of that, all character devices are listed on /sys/dev/char.</p>
<p>If you don&#8217;t have anything in /proc or /sys or both, you should mount them by doing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>proc <span style="color: #000000; font-weight: bold;">/</span>proc <span style="color: #660033;">-t</span> proc
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>sys <span style="color: #000000; font-weight: bold;">/</span>sys <span style="color: #660033;">-t</span> sysfs</pre></div></div>

<p>If you don&#8217;t want to be bothered with than anymore, put them in /etc/fstab .</p>
<p>That should be it for the fb.</p>
<h1>Touchscreen configuration</h1>
<p>A nice &#8220;s3c2440-ts&#8221; driver should also be loaded when booting your board, it is responsible for providing the touchscreen input.</p>
<h2>Char device</h2>
<p>When booting, you can see that message: &#8220;input: s3c2410 TouchScreen as /devices/virtual/input/input1&#8243;. And indeed, if you go to the directory &#8220;/sys/devices/virtual/input/input1&#8243; (don&#8217;t forget to mount /sys), you&#8217;ll see some nice things.<br />
In this folder, 2 directories have interesting names: event1 and mouse0, and both of them have a &#8220;dev&#8221; file in their content. They contain major:minor addresses of their character devices. Hu ?<br />
event1 provide a &#8220;touchscreen&#8221; way to access to the touchscreen input while the mouse0 provide another abstraction that show the ts as a mice.<br />
To access them, we have to make a node in /dev as following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>input
<span style="color: #c20cb9; font-weight: bold;">mknod</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>input<span style="color: #000000; font-weight: bold;">/</span>ts c <span style="color: #000000;">13</span> <span style="color: #000000;">65</span> <span style="color: #666666; font-style: italic;"># (from event1/dev)</span>
<span style="color: #c20cb9; font-weight: bold;">mknod</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>input<span style="color: #000000; font-weight: bold;">/</span>mice c <span style="color: #000000;">13</span> <span style="color: #000000;">32</span> <span style="color: #666666; font-style: italic;"># (from mouse0/dev)</span></pre></div></div>

<p>BTW, I kind of discovered the mouse input after doing what&#8217;s next, but I didn&#8217;t really had good results with that abstraction.</p>
<h2>tslib</h2>
<p>In order to exploit what&#8217;s coming from /dev/input/ts (if you do &#8220;cat /dev/input/ts&#8221;, you should see some weird characters when touching the screen <img src='http://blog.cor-net.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ), we can use the tslib library.<br />
I followed <a href="http://linux-dvbh.blogspot.com/2006/12/tslib-download-and-cross-compile-for.html">that howto</a> to cross-compile it.</p>
<p>After the installation, you should be careful with the configuration.<br />
About the ts.conf, I just uncommented &#8220;module_raw input&#8221;.<br />
About the env variables, I exported as follow at first:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_TSEVENTTYPE</span>=INPUT
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_CONSOLEDEVICE</span>=none
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_FBDEVICE</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>fb0
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_TSDEVICE</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>input<span style="color: #000000; font-weight: bold;">/</span>ts
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_CALIBFILE</span>=
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_CONFFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ts.conf
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_PLUGINDIR</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ts</pre></div></div>

<p>As you can see &#8220;TSLIB_CALIBFILE&#8221; is empty, if you put something in it, all ts_* tools will quit with a nice Seg fault &#8230;<br />
Then calibrate your screen with &#8220;ts_calibrate /usr/etc/ts.calib&#8221; and a stylus. After that, calibration information&#8217;s will be stored in /usr/etc/ts.calib, data that you should put in the &#8220;TSLIB_CALIBFILE&#8221; env var.</p>
<p>If you want a more reliable configuration, put all those vars in the /etc/profile file, this will be load along with bash.</p>
<h1>Qt Embedded 4.5</h1>
<p>While the qt lib is a nice and heavy piece of work, cross-compiling is actually quite easy.</p>
<p>First you need to download the sources from Qt: <a href="http://get.qt.nokia.com/qt/source/qt-embedded-linux-opensource-src-4.5.2.tar.gz">http://get.qt.nokia.com/qt/source/qt-embedded-linux-opensource-src-4.5.2.tar.gz</a> (last version <a href="http://qt.nokia.com/downloads/embedded-linux-cpp">here</a>).</p>
<p>Untar it and then go in the directory.</p>
<p>First we need to provide what tools you&#8217;re going to use for cross-compiling the thing. On my host I use the toolchain provided by my openembedded installation, thus all my tools are starting by &#8220;arm-angstrom-linux-gnueabi-&#8221;. You have to modify the file</p>
<pre>mkspecs/qws/linux-arm-g++/qmake.conf</pre>
<p>to express what tools you want to use to cross-compile. Of course you have to do that according to your toolchain.<br />
BTW, if your toolchain is a path that&#8217;s only in your user PATH var, you might want to put the full path to your toolchain, otherwise there will be some problems when doing &#8220;sudo make install&#8221;.</p>
<p>Then, let&#8217;s configure:</p>
<pre>./configure -embedded arm -xplatform qws/linux-arm-g++ -prefix /usr/local/Qt -qt-mouse-tslib -little-endian</pre>
<p>The -prefix is telling Qt that it&#8217;s going to be installed in /usr/local/Qt : hu ? When I first compiled Qt, I had my sd card mounted on /media/disk, so I put -prefix /media/disk/usr/local/Qt as an option. While I had no problem for the installation, I had troubles running some examples, as they we&#8217;re looking for files in the prefix path and not the real path (which is /usr/local/Qt on the board). I played a bit with the options but didn&#8217;t find a nice way to do that, that&#8217;s why I did the really ugly hack that&#8217;s following. I&#8217;m looking for a better solution, so if anyone as any, please mail me &#8230;<br />
I simply did a symbolic link from /usr/local/Qt to /media/disk/usr/local/Qt by doing :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-sf</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>disk<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Qt <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Qt</pre></div></div>

<p>That&#8217;s really ugly cause cross-compilation and virtual installation should be done nicely in userspace, while here I use a system wide path to do the trick.</p>
<p>Then you simply have to do :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>It&#8217;s going to take a while so go drink a coffee and remember those nice times when you had fun installing a gentoo from stage1 on a k6-2 &#8230;</p>
<p>Then unmount your sd card and boot your board.</p>
<p>You first have to register the Qt lib dir, this two lines should do:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;/usr/local/Qt/lib&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ld.so.conf.d<span style="color: #000000; font-weight: bold;">/</span>qt.conf
ldconfig</pre></div></div>

<p>Then, in order to configure QWS to use the tslib driver, you have to</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">QWS_MOUSE_PROTO</span>=tslib:<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>input<span style="color: #000000; font-weight: bold;">/</span>ts</pre></div></div>

<p>as mentioned in <a href="http://doc.trolltech.com/4.5/qt-embedded-pointer.html">the Qt doc</a>.</p>
<p>And &#8230; that should be all.<br />
Have fun with Qt examples, starting by /usr/local/Qt/exemples/qws/mousecalibration in order to make sure that everything is all right.</p>
<h1>Other ressources</h1>
<ul>
<li><a href="http://labs.trolltech.com/blogs/2009/09/10/cross-compiling-qtx11/">Cross-compiling Qt/X11</a> Article on the Qt dev blog</li>
</ul>
<p></p>
<hr />
<p>Please comment this post, if you find any error or improvement I would be glad to take them in consideration <img src='http://blog.cor-net.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cor-net.org/embedded/mini2440/qt-45-on-mini2440/feed/</wfw:commentRss>
		<slash:comments>67</slash:comments>
		</item>
	</channel>
</rss>
