<?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>Jörg Rädler</title>
	<atom:link href="http://www.j-raedler.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.j-raedler.de</link>
	<description>programming &#124; simulation &#124; visualization</description>
	<lastBuildDate>Fri, 06 Aug 2010 08:02:07 +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>Reading Arexx TL-500 with Python on Linux &#8211; Part II</title>
		<link>http://www.j-raedler.de/2010/08/reading-arexx-tl-500-with-python-on-linux-part-ii/</link>
		<comments>http://www.j-raedler.de/2010/08/reading-arexx-tl-500-with-python-on-linux-part-ii/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 08:02:07 +0000</pubDate>
		<dc:creator>jraedler</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.j-raedler.de/?p=335</guid>
		<description><![CDATA[My first script was changed a little bit to get nicer output. It can now log the raw data received from the Arexx unit (in hexadecimal form) and uses separate log files for the sensors. Sensor numbers can be mapped to other names using a dictionary. I use two TL-3TSN, one TSN-50E (long range) and [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://www.j-raedler.de/2010/07/reading-data-from-the-arexx-tl-500-on-linux/">first script</a> was changed a little bit to get nicer output. It can now log the raw data received from the Arexx unit (in hexadecimal form) and uses separate log files for the sensors. Sensor numbers can be mapped to other names using a dictionary.</p>
<p>I use two TL-3TSN, one TSN-50E (long range) and one TSN-EXT44 (external), all values seem to be correct with this script.</p>
<div><a href="http://download.j-raedler.de/Python/pyArexx/tl500_v0.3.py" style="float: right; margin-right: 5px;">Download</a>
<pre class="python"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># -*- coding: utf-8 -*-</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">try</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff7700;font-weight:bold;">import</span> usb.<span style="color: black;">core</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">except</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #008000;">Exception</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;You need pyusb-1 to run this script!&quot;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">array</span>, <span style="color: #dc143c;">time</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">class</span> SimpleLogger:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, rawFileName<span style="color: black;">&#41;</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">rawFile</span> = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>rawFileName, <span style="color: #483d8b;">&quot;a&quot;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">sensorFiles</span> = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff7700;font-weight:bold;">def</span> log<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, data<span style="color: black;">&#41;</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">str</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> data<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        s = data<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> s <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">sensorFiles</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #008000;">self</span>.<span style="color: black;">sensorFiles</span><span style="color: black;">&#91;</span>s<span style="color: black;">&#93;</span> = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>s+<span style="color: #483d8b;">&quot;.log&quot;</span>, <span style="color: #483d8b;">&quot;a&quot;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">sensorFiles</span><span style="color: black;">&#91;</span>s<span style="color: black;">&#93;</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> % \</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: black;">&#40;</span><span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, data<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span>, data<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, data<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">sensorFiles</span><span style="color: black;">&#91;</span>s<span style="color: black;">&#93;</span>.<span style="color: black;">flush</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff7700;font-weight:bold;">def</span> logRaw<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, rawData<span style="color: black;">&#41;</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">rawFile</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%15f&quot;</span> % <span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff7700;font-weight:bold;">for</span> d <span style="color: #ff7700;font-weight:bold;">in</span> rawData:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #008000;">self</span>.<span style="color: black;">rawFile</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; %02X&quot;</span> % d<span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">rawFile</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">rawFile</span>.<span style="color: black;">flush</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">class</span> TL500:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, sensors=<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>, action=<span style="color: #008000;">None</span>, rawAction=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">sensors</span> = sensors</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">dev</span> = <span style="color: #008000;">None</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">action</span> = action</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">rawAction</span> = rawAction</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>._buffer = <span style="color: #dc143c;">array</span>.<span style="color: #dc143c;">array</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'B'</span>, <span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>*<span style="color: #ff4500;">64</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff7700;font-weight:bold;">def</span> connect<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">dev</span> = usb.<span style="color: black;">core</span>.<span style="color: black;">find</span><span style="color: black;">&#40;</span>idVendor=0x0451, idProduct=0x3211<span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.<span style="color: black;">dev</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #008000;">Exception</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Arexx TL-500 not found!&quot;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff7700;font-weight:bold;">def</span> loopCollect<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.<span style="color: black;">dev</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #008000;">self</span>.<span style="color: black;">connect</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>._buffer<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> = <span style="color: #ff4500;">4</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>.<span style="color: black;">dev</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span>0x1, <span style="color: #008000;">self</span>._buffer, <span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">1000</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #008000;">self</span>._buffer<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> = <span style="color: #ff4500;">3</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #008000;">self</span>.<span style="color: black;">dev</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span>0x1, <span style="color: #008000;">self</span>._buffer, <span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">1000</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            rawData = <span style="color: #008000;">self</span>.<span style="color: black;">dev</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span>0x81, <span style="color: #ff4500;">64</span>, <span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">1000</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #ff7700;font-weight:bold;">if</span> rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> != <span style="color: #ff4500;">0</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>.<span style="color: black;">rawAction</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                    <span style="color: #008000;">self</span>.<span style="color: black;">rawAction</span><span style="color: black;">&#40;</span>rawData<span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>.<span style="color: black;">action</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                    <span style="color: #008000;">self</span>.<span style="color: black;">action</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">processData</span><span style="color: black;">&#40;</span>rawData<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #dc143c;">time</span>.<span style="color: black;">sleep</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff7700;font-weight:bold;">def</span> processData<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, rawData<span style="color: black;">&#41;</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        sensor   = rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span>*<span style="color: #ff4500;">256</span> + rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        valueRaw = rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span>*<span style="color: #ff4500;">256</span> + rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        clock    = rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">9</span><span style="color: black;">&#93;</span>*<span style="color: #ff4500;">16777216</span> + rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">8</span><span style="color: black;">&#93;</span>*<span style="color: #ff4500;">65536</span> + \</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#93;</span>*<span style="color: #ff4500;">256</span> + rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #808080; font-style: italic;"># FIXME: this should changed for other sensor types</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        value    = <span style="color: #ff4500;">0.0078</span> * valueRaw</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff7700;font-weight:bold;">return</span> clock, <span style="color: #008000;">self</span>.<span style="color: black;">sensors</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span>sensor, sensor<span style="color: black;">&#41;</span>, valueRaw, value</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    logger = SimpleLogger<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;raw.txt&quot;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #808080; font-style: italic;"># these are the names of my sensors</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    sensors = <span style="color: black;">&#123;</span><span style="color: #ff4500;">11492</span>: <span style="color: #483d8b;">&quot;325_in&quot;</span>, <span style="color: #ff4500;">11772</span>: <span style="color: #483d8b;">&quot;325_out&quot;</span>, \</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff4500;">8857</span>: <span style="color: #483d8b;">&quot;325_srv&quot;</span>, <span style="color: #ff4500;">8480</span>: <span style="color: #483d8b;">&quot;323_in&quot;</span><span style="color: black;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    tl500 = TL500<span style="color: black;">&#40;</span>sensors=sensors, action=logger.<span style="color: black;">log</span>, rawAction=logger.<span style="color: black;">logRaw</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    errors = <span style="color: #ff4500;">0</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff7700;font-weight:bold;">while</span> errors &lt;= <span style="color: #ff4500;">1000</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff7700;font-weight:bold;">try</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            tl500.<span style="color: black;">loopCollect</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">Exception</span>, e:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #ff7700;font-weight:bold;">print</span> e</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            errors += <span style="color: #ff4500;">1</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.j-raedler.de/2010/08/reading-arexx-tl-500-with-python-on-linux-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using KDE&#8217;s kwallet with Firefox/Iceweasel</title>
		<link>http://www.j-raedler.de/2010/08/using-kdes-kwallet-with-firefoxiceweasel/</link>
		<comments>http://www.j-raedler.de/2010/08/using-kdes-kwallet-with-firefoxiceweasel/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 12:23:36 +0000</pubDate>
		<dc:creator>jraedler</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.j-raedler.de/?p=323</guid>
		<description><![CDATA[Konqueror is a good browser, but sometimes you need to use Firefox (called Iceweasel on Debian). I discovered a plugin to let FF store its passwords in kwallet, but after installation of the plugin all passwords were gone. Fortunately you can disable the plugin and the old passwords are still there. So if you want [...]]]></description>
			<content:encoded><![CDATA[<p>Konqueror is a good browser, but sometimes you need to use Firefox (called Iceweasel on Debian). I discovered a <a href="https://addons.mozilla.org/de/firefox/addon/49357/" target="_blank">plugin to let FF store its passwords in kwallet</a>, but after installation of the plugin all passwords were gone.</p>
<p>Fortunately you can disable the plugin and the old passwords are still there. So if you want to switch to this plugin you should use the following procedure:</p>
<ol>
<li>install the <a href="https://addons.mozilla.org/de/firefox/addon/2848/" target="_blank">Password Exporter plugin</a></li>
<li>export your passwords to a text file using the plugin</li>
<li>install the <a href="https://addons.mozilla.org/de/firefox/addon/49357/" target="_blank">kwallet plugin</a></li>
<li>import your password file using the Password Exporter plugin</li>
<li>check the entries in the section <em>Firefox </em>of your kwallet using the kwalletmanager</li>
<li>don't forget to delete the exported file</li>
</ol>
<p>This worked for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j-raedler.de/2010/08/using-kdes-kwallet-with-firefoxiceweasel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading data from the Arexx TL-500 on Linux</title>
		<link>http://www.j-raedler.de/2010/07/reading-data-from-the-arexx-tl-500-on-linux/</link>
		<comments>http://www.j-raedler.de/2010/07/reading-data-from-the-arexx-tl-500-on-linux/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 18:19:36 +0000</pubDate>
		<dc:creator>jraedler</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.j-raedler.de/?p=306</guid>
		<description><![CDATA[Some days ago I was looking for a temperature monitoring solution for some rooms and 19"-racks at the university. The Arexx TL-500 looked promising and I bought it. Unfortunately there are only Windows drivers available. But some people already analyzed the communication protocol and hacked a simple version of a linux driver: http://www.algorithm-forge.com/techblog/2010/01/linux-usb-driver-for-the-arexx-tl-500-–-part-ii/ There's even [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago I was looking for a temperature monitoring solution for some rooms and 19"-racks at the university. The <a href="http://www.arexx.com" target="_blank">Arexx</a> TL-500 looked promising and I bought it. Unfortunately there are only Windows drivers available. But some people already analyzed the communication protocol and hacked a simple version of a linux driver:</p>
<p><a href="http://www.algorithm-forge.com/techblog/2010/01/linux-usb-driver-for-the-arexx-tl-500-–-part-ii/" target="_blank">http://www.algorithm-forge.com/techblog/2010/01/linux-usb-driver-for-the-arexx-tl-500-–-part-ii/</a></p>
<p>There's even a small logger hardware (ARM-based) using this device:</p>
<p><a href="http://rndhax.blogspot.com/2010/03/friendlyarm-mini2440-arexx-tl-500.html" target="_blank">http://rndhax.blogspot.com/2010/03/friendlyarm-mini2440-arexx-tl-500.html</a></p>
<p>As a python fan I couldn't resist porting this to python to get a small and flexible script. It can be easily extended to save the data, create charts (maybe using matplotlib) or present a web interface.</p>
<p>By looking at the raw data I noticed that bytes 6 and 7 (maybe more?)  contain a time value. Maybe it counts the seconds since the  initialization of the device?</p>
<p>The first version of my script is mainly a port of the C program. The script uses <a href="http://sourceforge.net/projects/pyusb/" target="_blank">pyusb 1.0</a>, a python wrapper for libusb 1.0. You may have to install it manually, most linux distributions come with older versions.</p>
<div><a href="http://download.j-raedler.de/Python/pyArexx/tl500_v0.2.py" style="float: right; margin-right: 5px;">Download</a>
<pre class="python"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">import</span> usb.<span style="color: black;">core</span>, <span style="color: #dc143c;">array</span>, <span style="color: #dc143c;">time</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">def</span> getData<span style="color: black;">&#40;</span>rawData<span style="color: black;">&#41;</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        sensor = rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span> * <span style="color: #ff4500;">256</span> + rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        tempRaw = rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span> * <span style="color: #ff4500;">256</span> + rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        clock = rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#93;</span> * <span style="color: #ff4500;">256</span> + rawData<span style="color: black;">&#91;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        temp = <span style="color: #ff4500;">0.0078</span> * tempRaw</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff7700;font-weight:bold;">return</span> clock, sensor, tempRaw, temp</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">def</span> collect<span style="color: black;">&#40;</span>dev<span style="color: black;">&#41;</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        dataDown = <span style="color: #dc143c;">array</span>.<span style="color: #dc143c;">array</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'B'</span>, <span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>*<span style="color: #ff4500;">64</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        dataDown<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> = <span style="color: #ff4500;">4</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        dev.<span style="color: black;">write</span><span style="color: black;">&#40;</span>0x1, dataDown, <span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        dataDown<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> = <span style="color: #ff4500;">3</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                dev.<span style="color: black;">write</span><span style="color: black;">&#40;</span>0x1, dataDown, <span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                rd = dev.<span style="color: black;">read</span><span style="color: black;">&#40;</span>0x81, <span style="color: #ff4500;">64</span>, <span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                <span style="color: #ff7700;font-weight:bold;">if</span> rd<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> != <span style="color: #ff4500;">0</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                        d = getData<span style="color: black;">&#40;</span>rd<span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                        <span style="color: #ff7700;font-weight:bold;">print</span> d</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                        logData<span style="color: black;">&#40;</span>d, rd<span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                <span style="color: #dc143c;">time</span>.<span style="color: black;">sleep</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">def</span> logData<span style="color: black;">&#40;</span>d, rd<span style="color: black;">&#41;</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        tmp = <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">str</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> rd<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        logfile.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s<span style="color: #000099; font-weight: bold;">\t</span>%d<span style="color: #000099; font-weight: bold;">\t</span>%d<span style="color: #000099; font-weight: bold;">\t</span>%d<span style="color: #000099; font-weight: bold;">\t</span>%g<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> % <span style="color: black;">&#40;</span><span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                d<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, d<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>, d<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>, d<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span>, tmp<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        dev = usb.<span style="color: black;">core</span>.<span style="color: black;">find</span><span style="color: black;">&#40;</span>idVendor=0x0451, idProduct=0x3211<span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        logfile = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;temp.txt&quot;</span>, <span style="color: #483d8b;">&quot;a&quot;</span><span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        collect<span style="color: black;">&#40;</span>dev<span style="color: black;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
</div>
<p>I plan to extend this to a python package using OO, cleaner interfaces, better error handling and more.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j-raedler.de/2010/07/reading-data-from-the-arexx-tl-500-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>processing &#124; poor man&#8217;s evolution</title>
		<link>http://www.j-raedler.de/2010/07/processing-poor-mans-evolution/</link>
		<comments>http://www.j-raedler.de/2010/07/processing-poor-mans-evolution/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 13:26:33 +0000</pubDate>
		<dc:creator>jraedler</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[digi-pro]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.j-raedler.de/?p=236</guid>
		<description><![CDATA[This is an example from my generative design class of the digi-pro project. Genetic or evolutionary approaches are used to solve a wide range of problems with the computer. Many algorithms try to reproduce the mechanism of natural evolution as close as possible. They produce generations of slightly mutated information (DNA), combine the attributes of [...]]]></description>
			<content:encoded><![CDATA[<p>This is an example from my generative design class of the <a href="http://www.digi-pro.de/" target="_blank">digi-pro</a> project.</p>
<p>Genetic or evolutionary approaches are used to solve a wide range of problems with the computer. Many algorithms try to reproduce the mechanism of natural evolution as close as possible. They produce generations of slightly mutated information (DNA), combine the attributes of individuals, select the fittest and produce new generations.</p>
<p>This approach may solve many complex problems. But to get it working you have to do some serious programming and to tune a lot of parameters. In many cases a much simpler approach may be sufficient.</p>
<p>The next examples show a "poor man's evolution" to optimize a configuration. It just starts with a random configuration. One small change is made (random). If the result is better than before, the new configuration is used. If not, the change will be revoked. This process will continue in a loop. Thats all!</p>
<p>In the following example we want to place some elements on a plane. The only condition is that no overlapping happens and an additional distance between the element borders will be maintained. It starts with a random configuration (with overlapping). In every step one (randomly chosen) element is moved to a new random position. If the overall sum of overlapping is smaller than before, the new configuration is used. When a configuration is found that satisfies the condition, the background turns from blue to green and the search is turned off. Press "ALT-H" to toggle the visbility of the controls. By using the controls yout may start again and/or change the parameters.</p>
<iframe class="" src="http://download.j-raedler.de/Processing/EvoCircle/applet/index.html" style="width: 100%; height: 580px; " frameborder="0" scrolling="auto" onload="scro11me(this)"></iframe><script type="text/javascript">function scro11me(f){f.contentWindow.scrollTo(0,0); }</script>
<p>Source: <a href="http://download.j-raedler.de/Processing/EvoCircle" target="_blank">http://download.j-raedler.de/Processing/EvoCircle</a></p>
<p>You will see that the algorithm finds a solution with the default parameters within some seconds. But the result doesn't look nice in all cases. In a next step we will modify the criterion for the selection. Instead of summing up all overlappings we look at the minimum distance between two element borders. A new configuration is used only if this value is larger or equal to the old value. The decision to prefer the "'mutated" configuration even if its "fitness value" is the same brings some more noise to the process. This may help to find a better solution (recover from local optimums). The elements in this example will not move more than an allowed value. Use "ALT-H" again to toggle the controls.</p>
<iframe class="" src="http://download.j-raedler.de/Processing/EvoCircle3/applet/index.html" style="width: 100%; height: 580px; " frameborder="0" scrolling="auto" onload="scro11me(this)"></iframe><script type="text/javascript">function scro11me(f){f.contentWindow.scrollTo(0,0); }</script>
<p>Source: <a href="http://download.j-raedler.de/Processing/EvoCircle3" target="_blank">http://download.j-raedler.de/Processing/EvoCircle3</a></p>
<p>You will see that after some time a configuration with a very constant distribution of the elements will be found. If may not be the optimal distribution but a good one.</p>
<p>For special cases like 12 elements of the same size it will very often find the well-known analytical solution:</p>
<p><a href="http://www.j-raedler.de/wp-content/uploads/2010/07/evo3.png"><img class="aligncenter size-full wp-image-242" title="evo3" src="http://www.j-raedler.de/wp-content/uploads/2010/07/evo3.png" alt="special case: 12 elements  of the same size" width="255" height="265" /></a></p>
<p>This "poor man's evolution" is very easy to implement and may lead to good results in many cases. When you have an optimization problem you should consider using this super-simple approach first. If the results are not good enough you may switch to a full-fledged genetic algorithm.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j-raedler.de/2010/07/processing-poor-mans-evolution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>processing &#124; Koch-curve</title>
		<link>http://www.j-raedler.de/2010/07/processing-demo-koch-curve/</link>
		<comments>http://www.j-raedler.de/2010/07/processing-demo-koch-curve/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 10:30:58 +0000</pubDate>
		<dc:creator>jraedler</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[digi-pro]]></category>
		<category><![CDATA[fractal]]></category>
		<category><![CDATA[grasshopper]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.j-raedler.de/?p=223</guid>
		<description><![CDATA[This is another small demo from my generative design class of the digi-pro project. It draws a Koch curve using a recursive algorithm at variable depth. The horizontal mouse position is used for the depth value. By pressing the p-key you may toggle the drawing of small point markers. The c-key will export the points [...]]]></description>
			<content:encoded><![CDATA[<p>This is another small demo from my generative design class of the <a href="http://www.digi-pro.de/" target="_blank">digi-pro</a> project. It draws a Koch curve using a recursive algorithm at variable depth. The horizontal mouse position is used for the depth value. By pressing the p-key you may toggle the drawing of small point markers. The c-key will export the points to a simple CSV file. An example file for grasshopper shows how to read this points into the program.</p>
<iframe class="" src="http://download.j-raedler.de/Processing/KochCurve/applet/index.html" style="width: 100%; height: 400px; " frameborder="0" scrolling="auto" onload="scro11me(this)"></iframe><script type="text/javascript">function scro11me(f){f.contentWindow.scrollTo(0,0); }</script>
<p>Source: <a href="http://download.j-raedler.de/Processing/KochCurve/" target="_blank">http://download.j-raedler.de/Processing/KochCurve/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.j-raedler.de/2010/07/processing-demo-koch-curve/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>processing &#124; greatest common divisor</title>
		<link>http://www.j-raedler.de/2010/07/processing-demo-greatest-common-divisor/</link>
		<comments>http://www.j-raedler.de/2010/07/processing-demo-greatest-common-divisor/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 09:15:33 +0000</pubDate>
		<dc:creator>jraedler</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[digi-pro]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.j-raedler.de/?p=197</guid>
		<description><![CDATA[This is a small demo from my generative design class of the digi-pro project. It uses the euklidean algorithm to compute the greatest common divisor (GCD, GGT in german ) of two numbers. The mouse position (x, y) is used for the numbers. Press the keys 1, 2 or 3 to get different visualization methods [...]]]></description>
			<content:encoded><![CDATA[<p>This is a small demo from my generative design class of the <a href="http://www.digi-pro.de/" target="_blank">digi-pro</a> project. It uses the euklidean algorithm to compute the greatest common divisor (GCD, GGT in german ) of two numbers. The mouse position (x, y) is used for the numbers. Press the keys <em>1</em>, <em>2</em> or <em>3</em> to get different visualization methods of the results (you may need to click in the sketch once). The result is only shown if the GCD is greater than 3.</p>
<iframe class="" src="http://download.j-raedler.de/Processing/Euklid/applet/index.html" style="width: 100%; height: 350px; " frameborder="0" scrolling="auto" onload="scro11me(this)"></iframe><script type="text/javascript">function scro11me(f){f.contentWindow.scrollTo(0,0); }</script>
<p>Source: <a href="http://download.j-raedler.de/Processing/Euklid/" target="_blank">http://download.j-raedler.de/Processing/Euklid/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.j-raedler.de/2010/07/processing-demo-greatest-common-divisor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Janosch</title>
		<link>http://www.j-raedler.de/2010/06/janosch/</link>
		<comments>http://www.j-raedler.de/2010/06/janosch/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 09:30:30 +0000</pubDate>
		<dc:creator>jraedler</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[personal]]></category>

		<guid isPermaLink="false">http://www.j-raedler.de/?p=182</guid>
		<description><![CDATA[Janosch was born on 17.06.2010 at 21:12. He has a weight of 4010g and  a length of 56 cm. View pictures here (password required).]]></description>
			<content:encoded><![CDATA[<p>Janosch was born on 17.06.2010 at 21:12. He has a weight of 4010g and  a length of 56 cm.</p>
<p>View pictures <a href="http://www.j-raedler.de/personal/pictures">here</a> (password required).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j-raedler.de/2010/06/janosch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Triangle &#124; 1.0</title>
		<link>http://www.j-raedler.de/2010/06/triangle-1-0/</link>
		<comments>http://www.j-raedler.de/2010/06/triangle-1-0/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 09:37:31 +0000</pubDate>
		<dc:creator>jraedler</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[triangle]]></category>

		<guid isPermaLink="false">http://www.j-raedler.de/?p=149</guid>
		<description><![CDATA[The triangulation module for python based on Jonathan Richard Shewchuk's program Triangle was updated. It should work with recent versions of python 2.x now.]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.j-raedler.de/projects/Triangle">triangulation module</a> for python based on Jonathan Richard Shewchuk's program <a href="http://www.cs.cmu.edu/~quake/triangle.html">Triangle</a> was updated. It should work with recent versions of python 2.x now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j-raedler.de/2010/06/triangle-1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XMarshaL &#124; 1.0</title>
		<link>http://www.j-raedler.de/2010/06/xmarshal-1-0/</link>
		<comments>http://www.j-raedler.de/2010/06/xmarshal-1-0/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 09:30:42 +0000</pubDate>
		<dc:creator>jraedler</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[xmarshal]]></category>

		<guid isPermaLink="false">http://www.j-raedler.de/?p=147</guid>
		<description><![CDATA[My pickling/marshalling module for python was updated to work with recent python 2.x installations.]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://www.j-raedler.de/projects/XMarshaL">pickling/marshalling module</a> for python was updated to work with recent python 2.x installations.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j-raedler.de/2010/06/xmarshal-1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ncDataReader2 &#124; 2.2.0</title>
		<link>http://www.j-raedler.de/2010/06/ncdatareader2-2-2-0/</link>
		<comments>http://www.j-raedler.de/2010/06/ncdatareader2-2-2-0/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 19:06:33 +0000</pubDate>
		<dc:creator>jraedler</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[dymola]]></category>
		<category><![CDATA[modelica]]></category>
		<category><![CDATA[ncDataReader2]]></category>
		<category><![CDATA[netCDF]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[simulation]]></category>

		<guid isPermaLink="false">http://www.j-raedler.de/?p=134</guid>
		<description><![CDATA[A new release of ncDataReader2 is out. Changes include: switched from autoconf to cmake tested to compile on Linux, Windows and MacOS the easy API (EA) was completed EA works now with Modelica (Dymola): a weather file reader was implemented and tested with the  modelica library FluidFlow new documentation in english support for netCDF attributes [...]]]></description>
			<content:encoded><![CDATA[<p>A new release of <a href="http://www.j-raedler.de/projects/ncDataReader2">ncDataReader2</a> is out. Changes include:</p>
<ul>
<li>switched from autoconf to cmake</li>
<li>tested to compile on Linux, Windows and MacOS</li>
<li>the easy API (EA) was completed</li>
<li>EA works now with Modelica (Dymola):
<ul>
<li>a weather file reader was implemented and tested with the  modelica library FluidFlow</li>
</ul>
</li>
<li>new documentation in english</li>
<li>support for netCDF attributes was completed</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.j-raedler.de/2010/06/ncdatareader2-2-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
