<?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>JoPa.Fr &#187; Mir:ror</title>
	<atom:link href="http://www.jopa.fr/index.php/tag/mirror/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jopa.fr</link>
	<description>001100010BIDOUILLE11101010111100010LIBRE1000100111100101</description>
	<lastBuildDate>Tue, 10 Jan 2012 21:59:31 +0000</lastBuildDate>
	<language>fr</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Pam et Mir:ror : une authentification RFID sous Linux</title>
		<link>http://www.jopa.fr/index.php/2009/07/16/linux-pam-et-mirror-une-authentification-rfid/</link>
		<comments>http://www.jopa.fr/index.php/2009/07/16/linux-pam-et-mirror-une-authentification-rfid/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 23:10:03 +0000</pubDate>
		<dc:creator>Jopa</dc:creator>
				<category><![CDATA[Bidouilles]]></category>
		<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Planet-Libre]]></category>
		<category><![CDATA[Développement]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mir:ror]]></category>
		<category><![CDATA[rfid]]></category>
		<category><![CDATA[Sécurité]]></category>

		<guid isPermaLink="false">http://www.jopa.fr/?p=1461</guid>
		<description><![CDATA[Cette pluvieuse journée du 14 juillet m&#8217;a permis de poursuivre mes petits travaux sur le lecteur rfid &#171;&#160;Mir:ror&#160;&#187;. Dans les articles précédents, je me suis surtout intéressé au déclenchement d&#8217;événements en fonction des puces rfid détectées (ou pas) par le lecteur, oubliant l&#8217;essence même du RFID : l&#8217;authentification. J&#8217;ai donc profité de ce temps à [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img class="alignleft size-full wp-image-1462" title="pam_mirror" src="http://www.jopa.fr/wp-content/uploads/2009/07/pam_mirror.jpg" alt="pam_mirror" width="201" height="204" />Cette pluvieuse journée du 14 juillet m&#8217;a permis de poursuivre mes petits travaux sur le lecteur rfid &laquo;&nbsp;Mir:ror&nbsp;&raquo;. Dans les articles précédents, je me suis surtout intéressé au déclenchement d&#8217;événements en fonction des puces <em>rfid </em>détectées (ou pas) par le lecteur, oubliant l&#8217;essence même du RFID : l&#8217;authentification. J&#8217;ai donc profité de ce temps à ne pas mettre mon chat dehors pour écrire un module <a title="http://fr.wikipedia.org/wiki/Pluggable_Authentication_Modules" href="http://fr.wikipedia.org/wiki/Pluggable_Authentication_Modules">PAM (Pluggable Authentification Module)</a> permettant d&#8217;authentifier un utilisateur via le <em>Mir:ror</em>.</p>
<p style="text-align: justify;">L&#8217;idée est simple : si mon <em>Mir:ror</em> est connecté à l&#8217;ordinateur et qu&#8217;un fichier contenant mon <em>rfid </em>est présent dans mon répertoire, je veux pouvoir ouvrir ma session à l&#8217;aide d&#8217;une puce <em>RFID </em>(carte, badge, ztamp:s, laaaaapin&#8230;) à la place de saisir mon mot de passe.</p>
<p style="text-align: justify;"><span id="more-1461"></span></p>
<p style="text-align: justify;">Je ne vais pas m&#8217;attarder ici à décrire la manière dont est codé le module, je vous laisse le soin de lire les sources&#8230; Je vais me contenter d&#8217;expliquer son installation et son utilisation.</p>
<h2>Mise en garde :</h2>
<p style="text-align: justify;">Pour plusieurs raisons dont la simplification du module et mes piètres talents de développeur, il va sans dire que ce petit programme ne doit pas être utilisé en environnement sécurisé. Par contre, pour la maison, c&#8217;est plutôt fun !</p>
<p style="text-align: justify;"><em>Nous touchons ici à une partie sensible du système : l&#8217;authentification. Les manipulations ci-dessous sont donc à réaliser avec prudence.</em></p>
<h2>Compilation :</h2>
<p>Pour pouvoir compiler <em>pam_mir-ror</em>, il nous faut installer un version récente de la librairie de développement pam (libpam-dev). J&#8217;ai utilisé la version 1.0.1 proposée par défaut sous Debian Lenny.</p>
<p><span style="color: #800000;">$ sudo aptitude install libpam-dev</span></p>
<p>L&#8217;archive contenant les sources est téléchargeable ci-dessous :</p>
<ul>
<li><a href="http://www.jopa.fr/wp-content/uploads/2009/07/pam_mir-ror.0.2.tar.gz">pam_mir-ror.0.2.tar.gz</a></li>
</ul>
<p style="text-align: justify;">Une fois téléchargée, il faut la décompresser et tout simplement lancer la commande &laquo;&nbsp;make&nbsp;&raquo;.</p>
<p><span style="color: #800000;">$ tar -xvzf pam_mir-ror.0.2.tar.gz<br />
$ cd pam_mir-ror.0.2<br />
$ make</span></p>
<p style="text-align: justify;">Si tout se passe bien, nous devrions obtenir deux binaires :</p>
<ul style="text-align: justify;">
<li>read_mir-ror : Un petit outil permettant la lecture à partir du Mir:ror,</li>
<li style="text-align: justify;">pam_mir-ror.so : Le module pam.</li>
</ul>
<h2 style="text-align: justify;">read_mir-ror</h2>
<p style="text-align: justify;">Le petit outil read_mir-ror va nous permettre de tester le lecteur. Il suffit de l&#8217;exécuter et d&#8217;approcher une puce rfid.</p>
<p style="text-align: justify;"><span style="color: #800000;">$ sudo ./read_mirror<br />
0000D0081A025303420200D2</span></p>
<p style="text-align: justify;">La série de chiffres affichée n&#8217;est rien d&#8217;autre que l&#8217;ID de l&#8217;objet détecté.</p>
<p style="text-align: justify;"><em>Il est préférable d&#8217;utiliser read_mirror avec les droits root, au moins la première fois, pour l&#8217;accès au périphérique mir:ror. Par défaut, le mir:ror n&#8217;est accessible que par root. Les droits du handler sont changés à la première utilisation de la fonction de détection (inclue dans l&#8217;outil et le module). Il serait certainement plus propre de coder un petit outil qui serait automatiquement lancé par udev ou hotplug au branchement du Mir:ror, mais pour un module PAM, ce n&#8217;est pas très important.<br />
</em></p>
<h2 style="text-align: justify;">Génération du fichier utilisateur</h2>
<p style="text-align: justify;">Le même outil (read_mir-ror), va nous permettre de générer le fichier <em>.authtag </em>contenant le rfid propre à chaque utilisateur :</p>
<p style="text-align: justify;">Pour l&#8217;utilisateur courant :</p>
<p style="text-align: justify;"><span style="color: #800000;">$ sudo ./read_mirror &gt; ~/.authtag<br />
$ sudo chmod 400 ~/.authtag</span></p>
<p style="text-align: justify;">Pour un autre utilisateur  (toto):</p>
<p style="text-align: justify;"><span style="color: #800000;">$ sudo ./read_mirror &gt; /home/toto/.authtag<br />
$ sudo chmod 400 /home/toto/.authtag</span></p>
<p style="text-align: justify;">Il faut bien entendu présenter la puce au lecteur juste après la commande <em>./read_mirror</em>.<br />
Le fichier .authtag doit maintenant contenir le tag :</p>
<p><span style="color: #800000;">$ cat ~/.authtag</span><br />
<span style="color: #800000;">0000D0081A025303420200D2</span></p>
<h2 style="text-align: justify;">Module PAM  :  pam_mir:ror.so</h2>
<p style="text-align: justify;">Pour qu&#8217;il soit utilisable par PAM, il faut que <em>pam_mir:ror.so</em> soit présent dans /lib/security (lib64/security pour une architecture 64 bits)</p>
<p style="text-align: justify;"><span style="color: #800000;">$ sudo cp pam_mir-ror.so /lib/security</span></p>
<p style="text-align: justify;">ou pour un module 64 bits :</p>
<p style="text-align: justify;"><span style="color: #800000;">$ sudo cp pam_mir-ror.so /lib64/securit</span>y</p>
<p style="text-align: justify;">La dernière étape va être l&#8217;ajout du module à PAM. Pour cela, il nous faut éditer le fichier :<br />
<em>/etc/pam.d/common-auth </em>pour y ajouter, avant les modules pam_unix.so ou pam_unix2.so :</p>
<p style="text-align: justify;"><em>auth             sufficient         pam_mir-ror.so</em></p>
<p style="text-align: justify;"><em>/etc/pam.d/common-auth</em></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1461code2'); return false;">View Code</a> INI</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14612"><td class="code" id="p1461code2"><pre class="ini" style="font-family:monospace;">#
# /etc/pam.d/common-auth - authentication settings common to all services
...
auth    sufficient                      pam_mir-ror.so
# here are the per-package modules <span style="">&#40;</span>the <span style="color: #933;">&quot;Primary&quot;</span> block<span style="">&#41;</span>
auth    <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>success<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">1 default=ignore<span style="">&#93;</span></span>      pam_unix.so nullok_secure</span>
# here's the fallback if no module succeeds
auth    requisite                       pam_deny.so
# prime the stack with a positive return value if there isn't one already<span style="color: #666666; font-style: italic;">;</span>
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
auth    required                        pam_permit.so
# and here are more per-package modules <span style="">&#40;</span>the <span style="color: #933;">&quot;Additional&quot;</span> block<span style="">&#41;</span>
# end of pam-auth-update config</pre></td></tr></table></div>

<p style="text-align: justify;">Avant de rebooter frénétiquement la machine pour voir ce que ça peut donner avec <em>gdm</em>,  je conseille vivement de tester sur une console (crtl-alt-F1 par exemple)&#8230; Comme expliqué en début d&#8217;article, nous touchons ici à une partie sensible du système et c&#8217;est mieux de garder la main pour éviter des pirouettes telles qu&#8217;un redémarrage en single user ou à partir d&#8217;un liveCD pour réparer.</p>
<p style="text-align: justify;">J&#8217;ai fait en sorte que le module loggue un minimum. En fonction du système, ces logs sont visibles dans /var/log/auth.log ou /var/log/syslog.</p>
<p style="text-align: justify;"><a href="http://www.jopa.fr/wp-content/uploads/2009/07/shell1.png"><img class="aligncenter size-full wp-image-1478" title="shell" src="http://www.jopa.fr/wp-content/uploads/2009/07/shell1.png" alt="shell" width="457" height="263" /></a></p>
<p style="text-align: justify;">Dernière version des sources : <a href="http://www.jopa.fr/wp-content/uploads/2009/07/pam_mir-ror.0.2.tar.gz">pam_mir-ror.0.2.tar.gz</a></p>
<p style="text-align: justify;">
<p style="text-align: justify;">
<p style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://www.jopa.fr/index.php/2009/07/16/linux-pam-et-mirror-une-authentification-rfid/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Mir:ror mon beau Mir:ror&#8230;Comment puis-je te comprendre ?</title>
		<link>http://www.jopa.fr/index.php/2009/07/12/violet-mirror-acces-device-c/</link>
		<comments>http://www.jopa.fr/index.php/2009/07/12/violet-mirror-acces-device-c/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 00:22:12 +0000</pubDate>
		<dc:creator>Jopa</dc:creator>
				<category><![CDATA[Bidouilles]]></category>
		<category><![CDATA[Divers]]></category>
		<category><![CDATA[Planet-Libre]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Développement]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mir:ror]]></category>
		<category><![CDATA[rfid]]></category>

		<guid isPermaLink="false">http://www.jopa.fr/?p=1415</guid>
		<description><![CDATA[Dans mon précédent article, je présentais mir:ror, le petit lecteur RFID commercialisé par la société Violet.  Après avoir survolé leur application &#171;&#160;Mirware&#160;&#187; et mis en évidence les limites de son utilisation, je vais mettre &#171;&#160;les mains dans le cambouis&#160;&#187; pour essayer de comprendre comment communiquer avec Mir:ror.  L&#8217;idée étant de pouvoir coder de petits outils [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img class="alignright size-medium wp-image-1437" title="miror" src="http://www.jopa.fr/wp-content/uploads/2009/07/miror-300x254.jpg" alt="miror" width="184" height="156" />Dans mon <a title="http://www.jopa.fr/index.php/2009/07/07/violet-mirror-linux" href="http://www.jopa.fr/index.php/2009/07/07/violet-mirror-linux">précédent article</a>, je présentais <em>mir:ror</em>, le petit lecteur RFID commercialisé par la société <a title="http://www.violet.net/" href="http://www.violet.net/">Violet</a>.  Après avoir survolé leur application &laquo;&nbsp;Mirware&nbsp;&raquo; et mis en évidence les limites de son utilisation, je vais mettre &laquo;&nbsp;les mains dans le cambouis&nbsp;&raquo; pour essayer de comprendre comment communiquer avec Mir:ror.  L&#8217;idée étant de pouvoir coder de petits outils capables de réagir à des tags RFID.</p>
<p style="text-align: justify;"><span id="more-1415"></span></p>
<p style="text-align: justify;">D&#8217;un point de vu système, Mir:ror est directement reconnu sous Linux et accessible via le handler de périphérique /dev/hidraw<em>X</em> (où <em>X</em> est le numéro de périphérique, normalement &laquo;&nbsp;0&#8243; si c&#8217;est le premier appareil du genre connecté).</p>
<p style="text-align: justify;">La petite application &laquo;&nbsp;<em>discover-device</em>&laquo;&nbsp;, fournie avec <em>Mirware</em>, permet de le détecter automatiquement :</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-1417" title="discover-device" src="http://www.jopa.fr/wp-content/uploads/2009/07/discover-device.png" alt="discover-device" width="457" height="246" /></p>
<p style="text-align: justify;">Attention tout de même aux droits, le périphérique n&#8217;est par défaut accessible que par <em>root</em>, il faudra lui changer les droits ou utiliser le script &laquo;&nbsp;<em>installer.sh</em>&nbsp;&raquo; pour le faire, avant de pouvoir l&#8217;exploiter avec un utilisateur standard.</p>
<p style="text-align: justify;">Commençons par voir ce qu&#8217;il se passe avec un simple &laquo;&nbsp;cat&nbsp;&raquo; du fichier :</p>
<p style="text-align: justify;"><img class="size-full wp-image-1421 aligncenter" title="cat-miror" src="http://www.jopa.fr/wp-content/uploads/2009/07/cat-miror.png" alt="cat-miror" width="457" height="246" /></p>
<p style="text-align: justify;">Des hiéroglyphes s&#8217;affichent lorsque nous approchons ou retirons un tag&#8230; C&#8217;est plutôt bon signe, et visiblement c&#8217;est binaire ! Nous devrions y voir plus clair avec un affichage en hexadécimal.  <em>Hexdump</em> est idéal pour ça !</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-1422" title="hexdump" src="http://www.jopa.fr/wp-content/uploads/2009/07/hexdump.png" alt="hexdump" width="457" height="246" /></p>
<p style="text-align: justify;">La première ligne (0000 0000 0000 0000 0000 0000 0000 0000 *) nous indique que tant qu&#8217;il ne se passe rien, on lit des zéros&#8230; Où&#8230;Qu&#8217;on lit des zéros tant qu&#8217;il ne se passe rien ! (c&#8217;est plutôt normal).<br />
Les deux lignes suivantes (0102 0000 d008 1a02 5303 4202 00d2 0000 &#8211; 0000 0000 0000 0000 0000 0000 0000 0000) s&#8217;affichent lorsqu&#8217;un tag est approché, les deux dernières ( 0202 0000 d008 1a02 5303 4202 00d2 0000 &#8211; 0000 0000 0000 0000 0000 0000 0000 0000 ) lorsqu&#8217;on éloigne le tag.</p>
<p style="text-align: justify;">Après plusieurs tests, j&#8217;en déduis assez facilement que les deux premiers octets (0102 ou 0202) codent l&#8217;évènement. J&#8217;en ai repéré 4 types :</p>
<ul style="text-align: justify;">
<li>0&#215;0102 : Tag rfid détecté,</li>
<li>0&#215;0202 : Tag rfid retiré,</li>
<li>0&#215;0501 : Le mir:ror est mis à l&#8217;envert,</li>
<li>0&#215;0401 : Le mir:ror est remis à l&#8217;endroit.</li>
</ul>
<p style="text-align: justify;">Les 12 octets suivants semblent identifier la puce RFID.</p>
<p style="text-align: justify;">A titre de test, écrivons rapidement un petit bout de code C, prenant le device en paramètre et affichant les évènements et le tag associé :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1415code7'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14157"><td class="code" id="p1415code7"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Jopa - Petit test du Mir:ror : test_mirror.c</span>
<span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  FILE <span style="color: #339933;">*</span>mirror<span style="color: #339933;">;</span>
  <span style="color: #993333;">short</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> block<span style="color: #339933;">;</span>
  <span style="color: #993333;">short</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> event<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span> tag<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">25</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//Vérification du paramètre (device)</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>argc<span style="color: #339933;">!=</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Usage : %s mirror_device <span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Ouverture du fichier device</span>
  mirror <span style="color: #339933;">=</span> fopen<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;rb&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>mirror<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Accès à  %s impossible !<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Boucle en lecture</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     fread<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>event<span style="color: #339933;">,</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>mirror<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>event<span style="color: #339933;">!=</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Evenement detecté, lecture de l'ID</span>
        <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #0000dd;">6</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            fread<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>block<span style="color: #339933;">,</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>mirror<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            sprintf<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>tag<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">*</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;%04X&quot;</span><span style="color: #339933;">,</span>block<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">//Affichage en fonction de l'événement</span>
        <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Tag On</span>
            <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x102</span> <span style="color: #339933;">:</span>
                <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s : ON<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Tag Off</span>
             <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x202</span> <span style="color: #339933;">:</span>
                 <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s : OFF<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Mirror envers</span>
             <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x501</span> <span style="color: #339933;">:</span>
                 <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;MIR:ROR ENVERS<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Mirror endroit</span>
             <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x401</span> <span style="color: #339933;">:</span>
                   <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;MIR:ROR ENDROIT<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Default</span>
             <span style="color: #b1b100;">default</span> <span style="color: #339933;">:</span>
                   <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Evénement inconnu<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//switch</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//if (event</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//while (1)</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// main()</span></pre></td></tr></table></div>

<p style="text-align: justify;">En quelques lignes, nous ouvrons le périphérique dont le handler est passé en paramètre et bouclons sur sa lecture, 2 octets par 2 octets.<br />
Quand autre chose que &laquo;&nbsp;0&#8243; est détecté, c&#8217;est forcément un changement d&#8217;état. Nous lisons ensuite l&#8217;identifiant de la puce RFID.<br />
La dernière partie affiche un message en fonction de l&#8217;évènement détecté.</p>
<p style="text-align: justify;">Il ne reste plus qu&#8217;à le compiler et le tester :<br />
<span style="color: #800000;">$ gcc test_mirror.c -o test_mirror<br />
$ ./test_mirror</span></p>
<p><img class="aligncenter size-full wp-image-1434" title="test_mirror" src="http://www.jopa.fr/wp-content/uploads/2009/07/test_mirror.png" alt="test_mirror" width="497" height="331" /></p>
<p><span style="color: #800000;">Pour compléter l&#8217;exemple, nous pouvons rajouter l&#8217;exécution d&#8217;un script associé au tag et à son approche ou son éloignement. Les scripts pourraient être stockés dans le répertoire de l&#8217;utilisateur et porter l&#8217;<em>&lt;id&gt;-on.sh</em> ou l&#8217;<em>&lt;id&gt;-off.sh</em> comme nom. Pour l&#8217;exemple :</span></p>
<ul>
<li>0000D0081A025303420200D2-on.sh : Lancement de Firefox sur le blog de Jopa</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1415code8'); return false;">View Code</a> SH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14158"><td class="code" id="p1415code8"><pre class="sh" style="font-family:monospace;">#!/bin/sh
firefox http://www.jopa.fr</pre></td></tr></table></div>

<ul>
<li>0000D0081A025303420200D2-off.sh : Lancement de Thunderbird</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1415code9'); return false;">View Code</a> SH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14159"><td class="code" id="p1415code9"><pre class="sh" style="font-family:monospace;">#!/bin/sh
thunderbird</pre></td></tr></table></div>

<p><span style="color: #800000;">$ chmod +x ~/0000D0081A025303420200D2-*.sh</span></p>
<p style="text-align: justify;">Adaptons un peu le code en ajoutant une variable pour le nom du script et une commande &laquo;&nbsp;<em>system</em>&nbsp;&raquo; dans le <em>&laquo;&nbsp;switch/case&nbsp;&raquo;</em>.</p>
<p style="text-align: justify;">

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1415code10'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p141510"><td class="code" id="p1415code10"><pre class="c" style="font-family:monospace;">   <span style="color: #666666; font-style: italic;">// Jopa - Test Mir:ror</span>
&nbsp;
<span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  FILE <span style="color: #339933;">*</span>mirror<span style="color: #339933;">;</span>
  <span style="color: #993333;">short</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> block<span style="color: #339933;">;</span>
  <span style="color: #993333;">short</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> event<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span> tag<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">25</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// Ajout d'un variable script</span>
  <span style="color: #993333;">char</span> script<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">256</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//Vérification du paramètre (device)</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>argc<span style="color: #339933;">!=</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Usage : %s mirror_device <span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Ouverture du fichier device</span>
  mirror <span style="color: #339933;">=</span> fopen<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;rb&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>mirror<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Accès à  %s impossible !<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Boucle en lecture</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     fread<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>event<span style="color: #339933;">,</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>mirror<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>event<span style="color: #339933;">!=</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Evenement detecté, lecture de l'ID</span>
        <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #0000dd;">6</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            fread<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>block<span style="color: #339933;">,</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>mirror<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            sprintf<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>tag<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">*</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;%04X&quot;</span><span style="color: #339933;">,</span>block<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">//Affichage en fonction de l'événement</span>
        <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Tag On</span>
            <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x102</span> <span style="color: #339933;">:</span>
                <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s : ON<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//Construction du nom de script et exécution</span>
                sprintf<span style="color: #009900;">&#40;</span>script<span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;./%s-on.sh&quot;</span><span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                system<span style="color: #009900;">&#40;</span>script<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Tag Off</span>
             <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x202</span> <span style="color: #339933;">:</span>
                 <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s : OFF<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 <span style="color: #666666; font-style: italic;">//Construction du nom de script et exécution</span>
                 sprintf<span style="color: #009900;">&#40;</span>script<span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;./%s-off.sh&quot;</span><span style="color: #339933;">,</span>tag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 system<span style="color: #009900;">&#40;</span>script<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Mirror envers</span>
             <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x501</span> <span style="color: #339933;">:</span>
                 <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;MIR:ROR ENVERS<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Mirror endroit</span>
             <span style="color: #b1b100;">case</span> <span style="color: #208080;">0x401</span> <span style="color: #339933;">:</span>
                   <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;MIR:ROR ENDROIT<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">//Default</span>
             <span style="color: #b1b100;">default</span> <span style="color: #339933;">:</span>
                   <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Evénement inconnu&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//switch</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//if (event</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//while (1)</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// main()</span></pre></td></tr></table></div>

<p style="text-align: justify;">Ceci n&#8217;est bien entendu qu&#8217;un exemple, écrit rapidement et pas forcément très propre. Mais il permet de mettre en évidence la simplicité avec laquelle il est possible d&#8217;accéder à des informations RFID et ouvre la porte sur des développements qui peuvent être rapidement prometteurs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jopa.fr/index.php/2009/07/12/violet-mirror-acces-device-c/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Violet connecting objects</title>
		<link>http://www.jopa.fr/index.php/2009/07/07/violet-mirror-linux/</link>
		<comments>http://www.jopa.fr/index.php/2009/07/07/violet-mirror-linux/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 21:57:12 +0000</pubDate>
		<dc:creator>Jopa</dc:creator>
				<category><![CDATA[Bidouilles]]></category>
		<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Planet-Libre]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mir:ror]]></category>
		<category><![CDATA[rfid]]></category>

		<guid isPermaLink="false">http://www.jopa.fr/?p=1354</guid>
		<description><![CDATA[Vous connaissez certainement la société Violet et plus particulièrement son fameux lapin communicant : le Nabaztag ? Cette même société produit le &#171;&#160;mir:ror&#171;&#160;, un petit gadget très design qui n&#8217;est pas moins qu&#8217;un  lecteur RFID. Question coût, le mir:ror se trouve un peu partout pour un 50ène d&#8217;euros. J&#8217;ai déniché le mien en solde pour [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img class="alignleft size-medium wp-image-1355" title="mirror" src="http://www.jopa.fr/wp-content/uploads/2009/07/mirror-300x235.gif" alt="mirror" width="300" height="235" />Vous connaissez certainement la société <a title="Violet" href="http://www.violet.net" target="_blank">Violet </a>et plus particulièrement son fameux lapin communicant : le <a title="http://www.nabaztag.com/fr/index.html" href="http://www.nabaztag.com/fr/index.html" target="_blank">Nabaztag </a>? Cette même société produit le &laquo;&nbsp;<a title="http://www.violet.net/_mirror-le-premier-lecteur-rfid.html" href="http://www.violet.net/_mirror-le-premier-lecteur-rfid.html" target="_blank">mir:ror</a>&laquo;&nbsp;, un petit gadget très design qui n&#8217;est pas moins qu&#8217;un  lecteur <a title="http://fr.wikipedia.org/wiki/Radio-identification" href="http://fr.wikipedia.org/wiki/Radio-identification" target="_blank">RFID.</a></p>
<p style="text-align: justify;">Question coût, le <em>mir:ror</em> se trouve un peu partout pour un 50ène d&#8217;euros. J&#8217;ai déniché le mien en solde pour moins de 30 € &#8211; <em>Tu vois chérie, moi aussi le fais les soldes  !!!</em> &#8211; Dans un joli coffret, sont rangés le lecteur <em>usb</em>, 3 &laquo;&nbsp;timbres&nbsp;&raquo; autocollants (<a title="http://www.violet.net/_ztamps-rfid-tag-that-give-powers-to-your-objects.html" href="http://www.violet.net/_ztamps-rfid-tag-that-give-powers-to-your-objects.html">Ztamp:s</a>) et 2 petits lapins (<a title="http://www.violet.net/_nanoztag-the-programmable-RFID-rabbit.html" href="http://www.violet.net/_nanoztag-the-programmable-RFID-rabbit.html">Nano:Ztag</a>), tous munis d&#8217;une puce RFID.<img class="alignright size-full wp-image-1365" title="nano1" src="http://www.jopa.fr/wp-content/uploads/2009/07/nano1.jpg" alt="nano1" width="80" height="138" /></p>
<p style="text-align: justify;">
<p style="text-align: justify;">Le lecteur fonctionne biensûr avec les objets commercialisés par <em>Violet</em>, mais aussi avec n&#8217;importe quel <em>tags RFID</em>, pourvu qu&#8217;il  respecte la norme <a title="http://en.wikipedia.org/wiki/ISO_14443A" href="http://en.wikipedia.org/wiki/ISO_14443A">ISO 14443 A ou B</a> &#8211; La carte de bus/métro de <em>Toulouse </em>fonctionne parfaitement par exemple.</p>
<p style="text-align: justify;">En utilisation standard, moyennant l&#8217;installation d&#8217;un petit logiciel (<a title="http://my.violet.net/mirror/choose_mirware" href="http://my.violet.net/mirror/choose_mirware">Mirware</a>) et la création d&#8217;un compte (gratuit) sur le site de Violet, nous pourrons enregistrer nos objets RFID et associer une action à leur approche ou leur éloignement du lecteur.</p>
<p style="text-align: justify;"><img class="alignleft size-full wp-image-1369" title="ztamps" src="http://www.jopa.fr/wp-content/uploads/2009/07/ztamps.gif" alt="ztamps" width="110" height="110" />Après tout ce vocabulaire &laquo;&nbsp;<em>Nabaztanique</em>&laquo;&nbsp;, il faut bien que j&#8217;avoue que ce n&#8217;est pas pour son utilisation standard que j&#8217;ai craqué, mais pour  les  perspectives prometteuses  offertes en terme de bidouillage : <em>Authentification pam</em>, <em>évènements domotiques (X10)</em>, <em>clef de chiffrement</em>, on peut imaginer énormément d&#8217;usages &laquo;&nbsp;<em>non-officiels</em>&nbsp;&raquo; &#8230; et c&#8217;est ça qui est bon !</p>
<p style="text-align: justify;">Néanmoins, dans la suite du billet, je vais balayer une installation classique du &laquo;&nbsp;<em>Mirware</em>&nbsp;&raquo; sous <em>Linux. </em>Il faut bien commencer par là !<em> </em>Cette manipulation ne présente pas de difficulté particulière, à part peut-être pour les architectures <em>64 bits</em>. Dans un prochain article, je m&#8217;intéresserai au développements possibles autour du joujou !</p>
<p style="text-align: justify;"><span id="more-1354"></span></p>
<h2 style="text-align: justify;">Mirware mon beau Mirware&#8230;</h2>
<p style="text-align: justify;">J&#8217;ai réalisé ce test sur deux machines sous Ubuntu (9.04 &laquo;&nbsp;Jaunty jackalope&nbsp;&raquo; ), l&#8217;une en 32 bits, l&#8217;autre en 64. Mais <em>Mirware</em> devrait fonctionner sous n&#8217;importe quelle distribution, le tout étant de bien installer les librairies nécessaires.</p>
<p style="text-align: justify;">Dans les pré-requis, il faut bien entendu une machine sous <em>Linux</em>, disposant d&#8217;une interface graphique et connectée à Internet. En effet, <em>Mirware</em> fonctionne grâce au serveur <em>Violet.net</em>, sur lequel seront enregistrés les <em>tags </em>et les actions qui leurs sont associées.  C&#8217;est un peu limitant, mais comment dire&#8230;.c&#8217;est comme ça ! Domage !</p>
<p style="text-align: justify;">L&#8217;application est disponible <a title="http://my.violet.net/mirror/choose_mirware" href="http://my.violet.net/mirror/choose_mirware">ici</a> en version alpha&#8230; On regrettera l&#8217;absence des sources, mis à part pour la partie concernant la détection du périphérique, ce qui va sauver l&#8217;installation sur une distribution 64 bits.</p>
<p style="text-align: justify;">Je parlais de librairies, il nous faudra satisfaire quelques dépendances à ce sujet et en installer 3 principales :</p>
<ul>
<li>Qt 4.4 avec le module webkit,</li>
<li>QCA 2.0.1,</li>
<li>SDL 1.2</li>
</ul>
<p>(cf le README pour plus d&#8217;infos)</p>
<p style="text-align: justify;"><span style="color: #800000;">$ sudo apt-get install   libqt4-webkit   libqca2   libsdl1.2debian</span></p>
<p style="text-align: justify;"><span style="color: #800000;"><span style="color: #333333;">Nous pouvons à présent télécharger et installer le Mirware :</span></span></p>
<p style="text-align: justify;"><span style="color: #800000;"><span style="color: #333333;"><span style="color: #800000;">$ wget -c</span> </span>http://broad.violet.net/mirror/mirware.tar.gz<br />
$ tar -xvzf mirware.tar.gz<br />
$ cd mirware-0.9.9-1724<br />
$ sudo ./installer.sh<br />
</span></p>
<p style="text-align: justify;"><span style="color: #333333;">Le script <em>installer.sh</em>, présent dans l&#8217;archive de Mirware, va juste caler les droits pour la détection du périphérique :<br />
</span></p>
<p style="text-align: justify;"><span style="color: #800000;"><em><span style="color: #333333;">installer.sh ( pour information uniquement)</span></em><br />
</span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1354code12'); return false;">View Code</a> SH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p135412"><td class="code" id="p1354code12"><pre class="sh" style="font-family:monospace;">#!/bin/bash
[ &quot;$(id -u)&quot; -eq 0 ] || { echo &quot;This script needs root credentials&quot; ; exit 1 ; }
chown root discover-device || { echo &quot;Could not change owner of discover-device to root. Do you have root credentials ?&quot; ; exit 1 ; }
chmod a+s discover-device || exit 1
touch detected_device
&nbsp;
echo &quot;All done ! You can now plug a mir:ror and launch mirware-launcher.sh !&quot;</pre></td></tr></table></div>

<p style="text-align: justify;">Il ne reste plus qu&#8217;à connecter le<em> mir:ror</em> et  lancer mirware :</p>
<p><span style="color: #800000;">$ ./mirware-launcher.sh</span></p>
<p style="text-align: justify;"><img class="size-full wp-image-1398 alignleft" title="icone_notif" src="http://www.jopa.fr/wp-content/uploads/2009/07/icone_notif.png" alt="icone_notif" width="113" height="62" />Une icône dans la barre de notification indique que tout se passe bien. En approchant un objet du capteur, une fenêtre de connexion devrait apparaître, suivie d&#8217;un interface permettant d&#8217;enregistrer l&#8217;objet et de lui associer des actions (applications).</p>
<p><img class="aligncenter size-medium wp-image-1399" title="connexion" src="http://www.jopa.fr/wp-content/uploads/2009/07/connexion-300x237.png" alt="connexion" width="300" height="237" /></p>
<p><img class="aligncenter size-medium wp-image-1400" title="mirware" src="http://www.jopa.fr/wp-content/uploads/2009/07/mirware-300x237.png" alt="mirware" width="300" height="237" /></p>
<h2>32 bits&#8230;C&#8217;est bien&#8230;mais 64 ?</h2>
<p style="text-align: justify;">Si vous utilisez une distribution 64 bits, il vous faudra recompiler le petit programme de détection du mir:ror : <em>discover-device</em> et installer les librairies utilisées par <em>Mirware</em> dans leur version 32 bits. Sans les sources et en l&#8217;abscence de version 64 bits, pas le choix&#8230;</p>
<p style="text-align: justify;">Concernant la compilation de <em>discover-device</em>, rien de bien sorcier, il faut juste ne pas oublier de lui redonner les bons droits&#8230;<br />
<span style="color: #800000;">$ sudo rm discover-device<br />
$ gcc discover-device.c -o discover-device<br />
$ sudo ./installer.sh</span></p>
<p style="text-align: justify;">Pour les librairies 32 bits, après avoir pas mal joué de l&#8217;<em>apt-get</em>, je suis tombé sur<a title="http://frozenfox.freehostia.com/cappy/getlibs" href="http://frozenfox.freehostia.com/cappy/getlibs"> un script</a> qui simplifie bien les choses (merci Cappy). <a title="http://ubuntuforums.org/showthread.php?t=474790" href="http://ubuntuforums.org/showthread.php?t=474790">Getlibs</a> prend en paramètre un binaire et télécharge les librairies dépendantes dans leurs versions 32 et 64 bits&#8230; Le pied !</p>
<p><span style="color: #800000;">$ wget -c http://frozenfox.freehostia.com/cappy/getlibs<br />
$ ./getlibs mirware</span></p>
<h2>Pour clore ce chapitre&#8230;</h2>
<p style="text-align: justify;">&#8230;sur une utilisation classique du <em>mir:ror</em>, je peux ajouter qu&#8217;une grande majorité des actions proposées par le serveur sont fonctionnelles sous Linux&#8230; L&#8217;ouverture d&#8217;un dossier, le chargement d&#8217;une url, l&#8217;accès à la messagerie, à un podcast ou une webradio, la lecture d&#8217;un texte en texttospeech et j&#8217;en passe&#8230;</p>
<p style="text-align: justify;">J&#8217;ai tout de même noté un problème gênant sur l&#8217;application permettant le lancement de scripts;  En effet, cette dernière ne sait gérer que des scripts <em>Windows/Dos batch </em>(.bat) ou des <em>AppleScripts(MacOsx)</em>. Ce n&#8217;est pas très gênant pour l&#8217;utilisation que je compte en faire et comme promis, je détaillerai, dans le prochain article comment s&#8217;affranchir des contraintes du serveur <em>Violet</em>.<em>net</em> pour passer de l&#8217;autre côté du mirroir.</p>
<p style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://www.jopa.fr/index.php/2009/07/07/violet-mirror-linux/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

