<?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>Madox.NET &#187; Mazda</title>
	<atom:link href="http://www.madox.net/blog/tag/mazda/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.madox.net/blog</link>
	<description>Perversions of an Engineer</description>
	<lastBuildDate>Mon, 30 Jan 2012 12:21:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Reverse Engineering the Mazda CAN Bus – Part 2</title>
		<link>http://www.madox.net/blog/2009/10/24/reverse-engineering-the-mazda-can-bus-%e2%80%93-part-2/</link>
		<comments>http://www.madox.net/blog/2009/10/24/reverse-engineering-the-mazda-can-bus-%e2%80%93-part-2/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 13:03:48 +0000</pubDate>
		<dc:creator>Madox</dc:creator>
				<category><![CDATA[Perverse Applications of Science...]]></category>
		<category><![CDATA[CAN Bus]]></category>
		<category><![CDATA[Chumby]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Mazda]]></category>

		<guid isPermaLink="false">http://www.madox.net/blog/?p=545</guid>
		<description><![CDATA[This is probably the most ridiculous way to reverse engineer something to date&#8230; a Chumby, an EasySync CAN Sniffer, PHP and JavaScript&#8230; but it works. Instead of designing and building my own daughter-board for the Chumby, I bought an EasySync CAN USB converter which only has one CAN interface [and its not worth buying two].  [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_546" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.madox.net/blog/wp-content/uploads/2009/10/Screenshot-CAN-Bus-Sniffer-Mozilla-Firefox.png"><img class="size-medium wp-image-546" title="Screenshot-CAN Bus Sniffer - Mozilla Firefox" src="http://www.madox.net/blog/wp-content/uploads/2009/10/Screenshot-CAN-Bus-Sniffer-Mozilla-Firefox-450x421.png" alt="HTML Can Sniffer" width="450" height="421" /></a><p class="wp-caption-text">HTML Can Sniffer</p></div>
<p>This is probably the most ridiculous way to <a href="http://www.madox.net/blog/2008/11/17/reverse-engineering-the-mazda-can-bus-part-1/" target="_blank">reverse engineer</a> something to date&#8230; a <a href="http://www.chumby.com/">Chumby</a>, an <a href="http://www.madox.net/blog/2009/06/30/easysync-usb-can-bus-adapter-works-great-in-ubuntu-after-some-fiddling/" target="_blank">EasySync CAN Sniffer</a>, PHP and JavaScript&#8230; but it works.</p>
<p><span id="more-545"></span></p>
<p>Instead of designing and building my own daughter-board for the Chumby, I bought an EasySync CAN USB converter which only has one CAN interface [and its not worth buying two].  This means I will have to use the Mazda&#8217;s MS-CAN bus only [That's where the fuel/trip computer information is].  Only one problem, I didn&#8217;t pay much attention to the MS-CAN bus before and the MS-CAN bus isn&#8217;t as interesting as the HS-CAN.</p>
<p>So new mission to find out what else is on the MS-CAN bus now.  Problem is, the nature of the information on the MS-CAN is different to the HS-CAN.  For example, something like Speed on the HS-CAN was pretty easy to decipher from just logging the data then plotting again.  Trying to figure out &#8216;door open&#8217; for example on the MS-CAN is a lot hard this way.</p>
<p>I needed a tool to help me decipher the secrets of the MS-CAN, and I ended up writing (copy and pasting from old code) a ridiculous combination of PHP scripts for the chumby, a JavaScript/HTML front end.  All done and tested in 2 hours (lots of copy and pasting&#8230;) it works quite well.</p>
<h2>How it works</h2>
<ul>
<li>A background PHP script talks to the EasySync converter and reads the CAN messages that is being sent on the bus and makes this available to another data retrieval PHP script via sessions.</li>
<li>The front end HTML/Javascript combination calls upon the data retrieval PHP, which feeds it XML on the messages for example the CAN Identifer and the timestamp.</li>
<li>The XML is parsed and is rendered into a table for display, data is refreshed at periodic intervals.</li>
<li>The Javascript compares the XML values with the already rendered values before updating to detect a change in value.  If there is a change, the background of the &#8216;byte&#8217; field changes.</li>
<li>A keypress monitor allows the user to &#8216;reset&#8217; the changed background colours.</li>
<li>Code attached below if you want to peek at the mess&#8230;</li>
</ul>
<h2>How I used it</h2>
<p>Basically sat in the car with the sniffer running and trying various combinations to see which bit/byte changed.  e.g. Run sniffer, open a door, see message &#8217;433&#8242; byte &#8217;0&#8242; change colour, write down what changed, reset fields, open another door/do something else.</p>
<p>There were a few useful fields that I found/reconfirmed.  Nothing too interesting though and alot is disappointing.  For example there is information regarding headlight high beam being on, but not just normal headlights.  I suppose that&#8217;s because the high beam is displayed on the instrument panel whilst normal headlights doesn&#8217;t display/do anything.</p>
<p>Another disappointing thing is that the &#8216;ass/arse sensor&#8217; (that&#8217;s what I call the passenger seat detection gizmo) is only a boolean signal&#8230;no pressure sensing in it at all.  Would have been useful if it was an analogue signal, could have been good for the mChumby display &#8211; &#8220;Warning, the girl on the passenger seat weighs 87kg, do not go on another date&#8221;.</p>
<p>I&#8217;ll be updating the new information to the <a href="http://www.madox.net/blog/2008/11/17/reverse-engineering-the-mazda-can-bus-part-1/" target="_blank">Mazda CAN Bus</a> page in the next couple of days&#8230; check back then to see what&#8217;s new.</p>
<p><a href="http://www.madox.net/blog/wp-content/uploads/2009/10/cansniffer.zip">Download cansniffer.zip</a> (There&#8217;s still a bug with the timestamp I&#8217;m too lazy to fix&#8230; disclaimer this is hobby/crappy code <img src='http://www.madox.net/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> )</p>
]]></content:encoded>
			<wfw:commentRss>http://www.madox.net/blog/2009/10/24/reverse-engineering-the-mazda-can-bus-%e2%80%93-part-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>mChumby &#8211; Test run</title>
		<link>http://www.madox.net/blog/2009/07/15/mchumby-test-run/</link>
		<comments>http://www.madox.net/blog/2009/07/15/mchumby-test-run/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 10:12:29 +0000</pubDate>
		<dc:creator>Madox</dc:creator>
				<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Perverse Applications of Science...]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[CAN Bus]]></category>
		<category><![CDATA[Chumby]]></category>
		<category><![CDATA[FTDI]]></category>
		<category><![CDATA[HaXe]]></category>
		<category><![CDATA[Mazda]]></category>

		<guid isPermaLink="false">http://www.madox.net/blog/?p=498</guid>
		<description><![CDATA[After getting my EasySync USB-Can Adapter it was time to resurrect the mChumby project.  The interface GUI design hasn&#8217;t changed much, namely because its been lying idle but I figured it is good enough to try putting it onto the car for a test run. I didn&#8217;t want to fiddle around with getting power to [...]]]></description>
			<content:encoded><![CDATA[<p>After getting my <a href="http://www.madox.net/blog/2009/06/30/easysync-usb-can-bus-adapter-works-great-in-ubuntu-after-some-fiddling/" target="_blank">EasySync USB-Can Adapter</a> it was time to resurrect the <a href="http://http://www.madox.net/blog/2009/03/23/mchumby-mazdamadox-chumby/" target="_blank">mChumby</a> project.  The <a href="http://www.madox.net/blog/2009/04/06/mchumby-interface-design/" target="_blank">interface GUI design</a> hasn&#8217;t changed much, namely because its been lying idle but I figured it is good enough to try putting it onto the car for a test run.</p>
<p>I didn&#8217;t want to fiddle around with getting power to the Chumby, so the test is simply using my trusty old laptop and the EasySync adapter.  Only the speedometer, the tachometer and the accelerator pedal position is attached because again I&#8217;m too lazy to fiddle with my cable layout and as such its connected to the <a href="http://www.madox.net/blog/mazda-can-bus/" target="_blank">Mazda HS-Can</a> bus only rather than the MS-Can where the <a href="http://www.madox.net/blog/2008/11/17/reverse-engineering-the-mazda-can-bus-part-1/" target="_blank">goodie trip computer information is contained.</a></p>
<p>Almost every concoction of technology is used ranging from CAN, USB, PHP, HTTP, Shared Memory, XML, Flash, to an obscure programming language called HaXe.  Here is the result :-</p>
<p><span id="more-498"></span></p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/1NRWEeg4KeE" /><embed type="application/x-shockwave-flash" width="425" height="350" src="http://www.youtube.com/v/1NRWEeg4KeE"></embed></object></p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/Y8t7p2WR_3k" /><embed type="application/x-shockwave-flash" width="425" height="350" src="http://www.youtube.com/v/Y8t7p2WR_3k"></embed></object></p>
<p>The flash movie was set to 6 frames per second and the responsiveness of the data was superb.  I think I&#8217;ve stated before that the CAN speed data differs to the one displayed on the instrumentation cluster and this again really shows at higher speeds.</p>
<p>All I need to do now is to try it on a <a href="http://www.chumby.com/" target="_blank">Chumby</a>, there should be no portability issues as I&#8217;ve tested both flash and php on the Chumby before.</p>
<p>So does anyone have any comments and suggestions on the GUI and what else I could put on it?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.madox.net/blog/2009/07/15/mchumby-test-run/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MChumby &#8211; Interface Design</title>
		<link>http://www.madox.net/blog/2009/04/06/mchumby-interface-design/</link>
		<comments>http://www.madox.net/blog/2009/04/06/mchumby-interface-design/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 14:31:39 +0000</pubDate>
		<dc:creator>Madox</dc:creator>
				<category><![CDATA[Perverse Applications of Science...]]></category>
		<category><![CDATA[Chumby]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Free Software]]></category>
		<category><![CDATA[Geany]]></category>
		<category><![CDATA[Gnash]]></category>
		<category><![CDATA[HaXe]]></category>
		<category><![CDATA[Mazda]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.madox.net/blog/?p=278</guid>
		<description><![CDATA[Working a 70 hour week dampened my enthusiasm for the MChumby but I managed to scrape a couple of hours today to try my hand with HaXe + Flash to prototype the Chumby Interface. A few interesting tidbits were learned from the experiments :- HaXe + Geany are great for developing flash widgets for the [...]]]></description>
			<content:encoded><![CDATA[<p>Working a 70 hour week dampened my enthusiasm for the <a href="http://www.madox.net/blog/2009/03/23/mchumby-mazdamadox-chumby/" target="_blank">MChumby</a> but I managed to scrape a couple of hours today to try my hand with <a href="http://www.haxe.org/" target="_blank">HaXe</a> + Flash to prototype the <a href="http://www.chumby.com/" target="_blank">Chumby</a> Interface.</p>
<div id="attachment_283" class="wp-caption aligncenter" style="width: 330px"><a href="http://www.madox.net/blog/wp-content/uploads/2009/04/screenshot-mchumbyswf-1.png"><img class="size-full wp-image-283" title="screenshot-mchumbyswf-1" src="http://www.madox.net/blog/wp-content/uploads/2009/04/screenshot-mchumbyswf-1.png" alt="Test of revised layout" width="320" height="265" /></a><p class="wp-caption-text">Test of revised layout</p></div>
<p>A few interesting tidbits were learned from the experiments :-</p>
<ol>
<li>HaXe + Geany are great for developing flash widgets for the Chumby</li>
<li>Gnash doesn&#8217;t render the same as Linux Adobe Flash</li>
<li>Chumby renders the same as Adobe Flash</li>
<li>Text vertical alignment in flash is crap</li>
</ol>
<p>A bit of background and a demo video of the widget on the Chumby after the break.</p>
<p><span id="more-278"></span></p>
<p>The <a href="http://www.madox.net/blog/2009/03/23/mchumby-mazdamadox-chumby/" target="_blank">last post</a> describes my resurrection of a two year old project.  Here&#8217;s a super short summary with many pictures, photos and videos!</p>
<h2>The original layout</h2>
<div id="attachment_279" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.madox.net/blog/wp-content/uploads/2009/04/layout.png"><img class="size-medium wp-image-279" title="layout" src="http://www.madox.net/blog/wp-content/uploads/2009/04/layout-450x249.png" alt="Original concept layout..." width="450" height="249" /></a><p class="wp-caption-text">Original concept layout...</p></div>
<h2>Original layout prototyped</h2>
<div id="attachment_282" class="wp-caption aligncenter" style="width: 330px"><a href="http://www.madox.net/blog/wp-content/uploads/2009/04/screenshot-file-home-madox-mchumby-mchumbyswf.png"><img class="size-full wp-image-282" title="screenshot-file-home-madox-mchumby-mchumbyswf" src="http://www.madox.net/blog/wp-content/uploads/2009/04/screenshot-file-home-madox-mchumby-mchumbyswf.png" alt="Test of original layout" width="320" height="265" /></a><p class="wp-caption-text">Test of original layout</p></div>
<p>I thought the speed gauge didn&#8217;t look too bad but I got convinced by a friend to redesign the layout.  Plus I really didn&#8217;t know why I needed a song name on the display or the blinker indicators&#8230;</p>
<h2>The revised layout</h2>
<div class="mceTemp mceIEcenter" style="text-align: left;">
<dl id="attachment_280" class="wp-caption aligncenter" style="width: 330px;">
<dt class="wp-caption-dt"><a href="http://www.madox.net/blog/wp-content/uploads/2009/04/layout2.png"><img class="size-full wp-image-280" title="layout2" src="http://www.madox.net/blog/wp-content/uploads/2009/04/layout2.png" alt="Revised layout" width="320" height="240" /></a></dt>
</dl>
<p>Revised layout legend/summary :-</p>
<ul style="text-align: left;">
<li>The speed gauge is the outer display.</li>
<li>The arcs are for the tachometer and accelerator position.</li>
<li>The yellow bar is like a fuel remaining indicator</li>
<li>Red boxes are for the transmission (mode/gear)</li>
<li>The cyan box is for a graph of&#8230; don&#8217;t know yet.  Speed graph? Fuel economy graph? Any suggestions?</li>
</ul>
</div>
<h2>Gah Gnash vs Adobe Flash</h2>
<p>I&#8217;ve been using Geany to write the HaXe code for this and it is pretty easy to link it in with Gnash to view the resultant Flash when compiling/executing.  So all it all it seemed like a good package for flash development until I realised Gnash doesn&#8217;t render quite the same as Adobe&#8230; (&#8220;Gah&#8221; is my sign of exasperation that Gnash renders the flash differently&#8230;).</p>
<p>That&#8217;s not the important bit&#8230;the important bit is that it doesn&#8217;t render like the Chumby either!!!  ARGH.  (P.S. The fault is with Gnash rendering textfields vertically centered whereas flash render&#8217;s them top aligned, easy enough to fix&#8230;)</p>
<div id="attachment_281" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.madox.net/blog/wp-content/uploads/2009/04/screenshot.png"><img class="size-medium wp-image-281" title="screenshot" src="http://www.madox.net/blog/wp-content/uploads/2009/04/screenshot-450x221.png" alt="Gnash vs Flash player in Ubuntu" width="450" height="221" /></a><p class="wp-caption-text">Gnash vs Flash player in Ubuntu</p></div>
<h2>
<p><div id="attachment_286" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.madox.net/blog/wp-content/uploads/2009/04/chumbygnashflash.jpg"><img class="size-medium wp-image-286" title="chumbygnashflash" src="http://www.madox.net/blog/wp-content/uploads/2009/04/chumbygnashflash-400x300.jpg" alt="Chumby vs Gnash vs Linux Flash" width="400" height="300" /></a><p class="wp-caption-text">Chumby vs Gnash vs Linux Flash</p></div></h2>
<h2>Chumby gesture interface test video</h2>
<p style="text-align: center;"><object classid="clsid:166b1bca-3f9c-11cf-8075-444553540000" width="320" height="240" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0"><param name="sound" value="true" /><param name="progress" value="true" /><param name="autostart" value="true" /><param name="swstretchstyle" value="none" /><param name="swstretchhalign" value="none" /><param name="swstretchvalign" value="none" /><param name="src" value="http://www.madox.net/blog/wp-content/uploads/2009/04/chumbydemo.flv" /><embed type="application/x-director" width="320" height="240" src="http://www.madox.net/blog/wp-content/uploads/2009/04/chumbydemo.flv" swstretchvalign="none" swstretchhalign="none" swstretchstyle="none" swliveconnect="false" autostart="true" progress="true" sound="true"></embed></object></p>
<p style="text-align: left;">Works pretty well I have to say <img src='http://www.madox.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   What do you think?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.madox.net/blog/2009/04/06/mchumby-interface-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mChumby &#8211; Mazda/Madox Chumby</title>
		<link>http://www.madox.net/blog/2009/03/23/mchumby-mazdamadox-chumby/</link>
		<comments>http://www.madox.net/blog/2009/03/23/mchumby-mazdamadox-chumby/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 11:38:11 +0000</pubDate>
		<dc:creator>Madox</dc:creator>
				<category><![CDATA[Perverse Applications of Science...]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[CAN Bus]]></category>
		<category><![CDATA[Free Software]]></category>
		<category><![CDATA[Mazda]]></category>
		<category><![CDATA[Microcontrollers]]></category>

		<guid isPermaLink="false">http://www.madox.net/blog/?p=271</guid>
		<description><![CDATA[It&#8217;s taken me a while to officially start this project.  When I first bought my Mazda 3 I had envisaged making my own speedometer based off the Mazda CAN Bus but somehow never quite got around to it. I even ended up buying 2 Chumbies for the purpose of hacking one and developing the same [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s taken me a while to officially start this project.  When I first bought my Mazda 3 I had envisaged making my own speedometer based off the Mazda CAN Bus but somehow never quite got around to it.</p>
<p>I even ended up buying 2 <a href="http://www.chumby.com/" target="_blank">Chumbies</a> for the purpose of hacking one and developing the same speedo (The chumby is such a great alarm clock I couldn&#8217;t live without one&#8230;).</p>
<p>There has been quite a bit of interest in the comments for source code/information etc etc.  So now I&#8217;m officially starting the mChumby project!  This first post is basically a brainstorming session write-up or a mini requirements specification on myself.  Feel free to comment on any ideas/improvements you think I can make.</p>
<p>(This post seems too wordy without a photo but I&#8217;m just too lazy)</p>
<h1><span id="more-271"></span>The concept</h1>
<p>A Chumby will connect via CAN Bus to the Mazda to offer an alternative &#8216;GUI&#8217; to the car.  Information such as fuel consumption that has been removed from the Australian Mazda&#8217;s will be displayed.</p>
<p>Since a chumby doesn&#8217;t have native CAN Bus connections, a custom daughter board with dual CAN controllers and transceivers will be built to replace the native Chumby power board.</p>
<h1>The hardware</h1>
<p>In addition to the Chumby mainboard, there will be a custom daughter board to be made to handle the car interface.  The Chumby has multiple SPI interfaces brought out through the &#8216;Chumbilical&#8217;, as well as on-board voltage regulators that will take up to 15V.  So a quick brainstorm on the daughter-board components leads me to :-</p>
<p>CAN Controller : MCP2515 &#8211; Has SPI interface, great for Chumby.<br />
CAN Transceiver : TJA1041 or whatever it is I have in my box of electronics &#8211; Because I have them already<br />
USB Connectors + Associated electronics&#8230;<br />
Automotive Voltage Suppressor : Vishay had a few good ones</p>
<p>Luxuries like accelerometers are too much of a pain to hand solder <img src='http://www.madox.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h1>The software</h1>
<p>I&#8217;m going to try use completely open source software in the development.  This will be discounting the Flash Lite 3 player that ships with the Chumby.  I debated much about developing a QT app or a flash widget, what I decided was undecided and I switched back and forth.  In the end, I&#8217;m sticking with Flash (for now).</p>
<p>There are two main pieces of software required, the GUI and the CAN Bus drivers.</p>
<p>The GUI as decided before will be Flash targetting the Flash Lite 3 on the Chumby.  For this I decided to use <a href="http://www.haxe.org/" target="_blank">HaXe</a>, which will happily compile to Flash 8 bytecode.  It is not as popular in open source flash developement as say ActionScript 2 with <a href="http://tech.motion-twin.com/mtasc.html" target="_blank">mtasc</a> but I figured I&#8217;ll use the newer language.  Unfortunately there is a severe lack of HaXe examples on the net and when you find them, you&#8217;ll find that its based on Flash 9 API&#8230; GAH.  However a little bit of experimentation and googling around made me see how easy it is to actually use HaXe.  More on this later.</p>
<p>The driver&#8217;s for the MCP2515&#8242;s I haven&#8217;t really looked at yet but I hope that it&#8217;ll be a simple matter of adapting MCP2515 code from elsewhere and merging it with hopefully some SPI driver&#8217;s in the Chumby kernel source (did I mention how great the Chumby is? Source code is made available!).</p>
<p>There is a bit of other software that&#8217;ll be used to create this project.  I&#8217;m planning on learning how to use <a href="http://http://iut-tice.ujf-grenoble.fr/kicad/" target="_blank">KiCAD</a> to generate the PCB where as I&#8217;ve only previously used<a href="http://cadsoftusa.com/" target="_blank"> Eagle</a> on my hobby projects.  While I&#8217;m sure Eagle will get the job done, I really want to give a try in learning how to use the open source KiCAD.  Let me know if you have any hints.</p>
<p><a href="http://www.geany.org/" target="_blank">Geany</a> will be my lightweight editor/IDE of choice, its so simple to use and amazing.  (I like <a href="http://notepad-plus.sourceforge.net/" target="_blank">Notepad++</a> in Windows but I haven&#8217;t booted Windows at home for a while&#8230;)</p>
<h1>The HMI</h1>
<p>I like easy to use and simple user interfaces.  This is especially true when I&#8217;m driving, I definitely do not want this thing distracting me.  My initial idea was to organise it such that all the &#8216;buttons&#8217; are on the corners of the screen but on second thought even trying to touch that while driving may be a bit difficult.</p>
<p>Current idea is to use some simple swipe gestures to control the screen.  The idea is to have minimal interaction with my mChumby as possible while driving.  I intend to have 2 screens, one to display a large speedo and the main displays and a second screen to display a smaller speed with alot of additional potentially useless information (I haven&#8217;t figured out what yet).  I will also need brightness control to avoid getting a super bright screen at night.  So simply, swipe left-right will allow me to change screens and wipe up-down will allow me to adjust backlight brightness.</p>
<h2>Below is just an embarassing sample of the HaXe code I was experimenting with&#8230;</h2>
<h3></h3>
<h3>Mchumby.hx</h3>
<blockquote>
<pre>//MChumby GUI - HaXe code targetting Flash 8

class Mchumby{
  //Gesture Variables
  static var fGestureStartX:Float;
  static var fGestureStartY:Float;
  static var fGestureEndX:Float;
  static var fGestureEndY:Float;
  static var fGestureDeltaX:Float;
  static var fGestureDeltaY:Float;

  //MovieClips (Screens)
  static var mcMain : flash.MovieClip;

  static var mcD100 : flash.MovieClip;
  static var mcD101 : flash.MovieClip;
  //MovieClips (Buttons/Other Elements)

  //Text Fields
  static var tfText : flash.TextField;

  static var tfSpeedo : flash.TextField;
  static var tfAccelX : flash.TextField;
  static var tfAccelY : flash.TextField;
  static var tfAccelZ : flash.TextField;  

  //Text Format/Styles
  static var ts = new flash.TextFormat();
  static var tsCenter = new flash.TextFormat();

  public function new(){
    //Constructor - Most items are moved to main();
    fGestureStartX=0;
    fGestureStartY=0;
  }

  static function main(){
    //Setup main MovieClip
    mcMain = flash.Lib.current;

    //Set up some font styles
    ts.font = "Arial";
    ts.size = 24;
    ts.color = 0x00FFFF;

    tsCenter.font = "Arial";
    tsCenter.size = 24;
    tsCenter.color = 0xFF0000;
    tsCenter.align = 'center';

    //Set up screens the new way
    //var m100 = new M100(mcMain);
    //var m101 = new M101(mcMain);

    //Set up screens
    mcD100 = mcMain.createEmptyMovieClip("D100", mcMain.getNextHighestDepth());
    mcD101 = mcMain.createEmptyMovieClip("D101", mcMain.getNextHighestDepth());

    //Set up text fields
    tfText = mcMain.createTextField("tfText", mcMain.getNextHighestDepth(), 20, 20, 280, 100);
    tfText.setNewTextFormat(tsCenter);

    //Set up text fields (D100)
    tfSpeedo = mcD100.createTextField("speedotext", mcD100.getNextHighestDepth(), 20,50,280,100);
    tfSpeedo.setNewTextFormat(ts);
    tfAccelX = mcD100.createTextField("accelx", mcD100.getNextHighestDepth(), 20,80,280,100);
    tfAccelX.setNewTextFormat(ts);
    tfAccelY = mcD100.createTextField("accely", mcD100.getNextHighestDepth(), 20,110,280,100);
    tfAccelY.setNewTextFormat(ts);
    tfAccelZ = mcD100.createTextField("accelz", mcD100.getNextHighestDepth(), 20,140,280,100);
    tfAccelZ.setNewTextFormat(ts);

    //Set up text fields (D101)

    //Initialise text
    tfText.text = 'Hello World!';

    tfSpeedo.text = 'Accelerometer Values...';

    //Set up event handlers
    mcMain.onMouseDown = startGesture;
    mcMain.onMouseUp = endGesture;
    mcMain.onEnterFrame = update;
  }

  static function update(){
    tfAccelX.text = Std.string(ChumbyNative.getAccelerometer(5));
    tfAccelY.text = Std.string(ChumbyNative.getAccelerometer(6));
    tfAccelZ.text = Std.string(ChumbyNative.getAccelerometer(7));
  }
  static function startGesture () {
    fGestureStartX = flash.Lib.current._xmouse;
    fGestureStartY = flash.Lib.current._ymouse;
  }

  static function endGesture () {
    fGestureEndX = flash.Lib.current._xmouse;
    fGestureEndY = flash.Lib.current._ymouse;
    fGestureDeltaX = Math.round(fGestureEndX - fGestureStartX);
    fGestureDeltaY = Math.round(fGestureEndY - fGestureStartY);

		//Rather than else-if, the following if's are deliberately done to allow compound gestures
		//e.g. Up &amp; Left, Down &amp; Right etc.
    if (!Math.isNaN(fGestureDeltaY) &amp;&amp; (fGestureDeltaY &gt; 100)) {
      gestureDown();
    }

    if (!Math.isNaN(fGestureDeltaY) &amp;&amp; (fGestureDeltaY &lt; -100)) {
      gestureUp();
    } 

    if (!Math.isNaN(fGestureDeltaX) &amp;&amp; (fGestureDeltaX &lt; -200)) {
      gestureLeft();
    }

    if (!Math.isNaN(fGestureDeltaX) &amp;&amp; (fGestureDeltaX &gt; 200)) {
      gestureRight();
    }
  }
  static function gestureRight () {
    tfText.text = "To the right!";
    mcD100._alpha = 0;
    //tfText.setTextFormat(ts);
  }
  static function gestureLeft () {
    tfText.text = "To the left!";
    mcD100._alpha = 100;
  }
  static function gestureUp () {
    tfText.text = "Bright!";
    ChumbyNative.setLCDMute(0);
  }
  static function gestureDown () {
    tfText.text = "Dim!";
    ChumbyNative.setLCDMute(1);
  }
}</pre>
</blockquote>
<h3>ChumbyNative.hx</h3>
<blockquote>
<pre>class ChumbyNative{
  public static function getLCDMute():Int{
    return flash.Lib._global.ASnative(5,19);
  }
  public static function setLCDMute(x:Int):Void{
    flash.Lib._global.ASnative(5,20)(x);
  }
  public static function getAccelerometer(x:Int):Float{
    return flash.Lib._global.ASnative(5,60)(x);
  }
}</pre>
</blockquote>
<h3>Mchumby.hxml</h3>
<blockquote><p>-swf mchumby.swf<br />
-main Mchumby<br />
-swf-header 320:240:12:000033<br />
-swf-version 8</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.madox.net/blog/2009/03/23/mchumby-mazdamadox-chumby/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Reverse Engineering the Mazda CAN Bus &#8211; Part 1</title>
		<link>http://www.madox.net/blog/2008/11/17/reverse-engineering-the-mazda-can-bus-part-1/</link>
		<comments>http://www.madox.net/blog/2008/11/17/reverse-engineering-the-mazda-can-bus-part-1/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 11:37:38 +0000</pubDate>
		<dc:creator>Madox</dc:creator>
				<category><![CDATA[Perverse Applications of Science...]]></category>
		<category><![CDATA[CAN Bus]]></category>
		<category><![CDATA[Mazda]]></category>
		<category><![CDATA[Perverted Engineering]]></category>

		<guid isPermaLink="false">http://www.madox.net/blog/?p=22</guid>
		<description><![CDATA[Controller-Area Network or CAN Bus is one of many automotive communication buses for communications between various &#8216;car computers&#8217;.  Information such as speed, fuel consumption, accelerator pedal position is all transmitted between the various controllers of a car akin to &#8216;fly-by-wire&#8217; control systems of aircraft but I guess &#8216;drive-by-wire&#8217; is more appropriate in this case. There [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Controller_Area_Network">Controller-Area Network</a> or CAN Bus is one of many automotive communication buses for communications between various &#8216;car computers&#8217;.  Information such as speed, fuel consumption, accelerator pedal position is all transmitted between the various controllers of a car akin to &#8216;fly-by-wire&#8217; control systems of aircraft but I guess &#8216;drive-by-wire&#8217; is more appropriate in this case.</p>
<p>There are other rival bus technologies include LIN (Local Interconnect Network) which is supposed to be a lower cost alternative to CAN, but I&#8217;m not interested in that.  Why?  My car uses the CAN bus, not LIN, not Ethernet.  So lets go about figuring what can be gleened from the communications whizzing around my car!</p>
<div id="attachment_28" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.madox.net/blog/wp-content/uploads/2008/11/carpig2.jpg"><img class="size-medium wp-image-28" title="carpig2" src="http://www.madox.net/blog/wp-content/uploads/2008/11/carpig2-300x225.jpg" alt="Aside from CAN bus, my car has a pig too.  This photo is from 2 years ago and the pig no longer has the tail or the tag on its ass..." width="300" height="225" /></a><p class="wp-caption-text">Aside from CAN bus, my car has a pig too (Long story).  This photo is from 2 years ago and the pig no longer has the weird thing hanging from its belly or the tag on its ass...</p></div>
<p><span id="more-22"></span></p>
<h2>Background / Reason Why</h2>
<p>In June 2006 I bought a &#8216;new&#8217; car, an Australian Mazda 3 Facelift Model.  The car was a great drive, Mazda excelled in the build and features but one thing nagged at me &#8211; the speedometer.  It was stylish I had to admit but the scaling was &#8216;off&#8217; to me.  0 speed was vertically down and the scaling was&#8230; better not rant on but the thought was &#8216;maybe I can get another speedometer on&#8217;.  A history of my &#8216;better speedometer&#8217; fantasies follow <img src='http://www.madox.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<div id="attachment_24" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.madox.net/blog/wp-content/uploads/2008/11/speed432.jpg"><img class="size-medium wp-image-24" title="speed432" src="http://www.madox.net/blog/wp-content/uploads/2008/11/speed432-300x266.jpg" alt="My old (and free!) Sony Ericson showing my speed on a MagLev" width="300" height="266" /></a><p class="wp-caption-text">My old (and free!) Sony Ericson showing my speed on a MagLev</p></div>
<div id="attachment_25" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.madox.net/blog/wp-content/uploads/2008/11/hudtest.jpg"><img class="size-medium wp-image-25" title="hudtest" src="http://www.madox.net/blog/wp-content/uploads/2008/11/hudtest-300x225.jpg" alt="Testing the feasibility of using the same crappy phone as a HUD on another car of mine on a rainy night..." width="300" height="225" /></a><p class="wp-caption-text">Testing the feasibility of using the same crappy phone as a HUD on another car of mine on a rainy night...yup that&#39;s the image on my windscreen!</p></div>
<p>A little bit of research later I found out the Mazda had two CAN buses: a &#8216;HS-CAN&#8217; (High Speed) network on which most of the essential systems (ECU, ABS) were connected, and a slower &#8216;MS-CAN&#8217; (Medium Speed?) network on which accessories such as the audio system were connected.  These two networks are joined together by the instrument panel which also acts as the gateway to allow some messages to pass between the two networks.  Both buses are conveniently available via a &#8216;standard&#8217; J1962 plug just below the steering wheel (Do a search on <a href="http://en.wikipedia.org/wiki/On_Board_Diagnostics">OBD</a>) so I didn&#8217;t have to hack anything open.</p>
<p>[Note : Most of the information below is from back in 2006, I only recently picked this project back up]</p>
<p>[Note 2 : Please don't any of what I say below if you're not familiar with electronics/cars or if you value your life... I hold no responsibility for anything that happens... I need to learn how to write a better disclaimer]</p>
<h2>So what is on the network exactly?</h2>
<p>Officially?  &#8216;I dunno&#8217;.  Mazda naturally doesn&#8217;t publish this information nor can it be found on the net easily, I hope Mazda doesn&#8217;t take offense at me writing this post actually&#8230; I loved the car and I&#8217;m doing this because its such a great car <img src='http://www.madox.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  [/grovel].</p>
<p>Now if that information isn&#8217;t forthcoming from the great ol&#8217; google, I just had to try figure it out for myself!</p>
<h2>How it was done</h2>
<p>First step &#8211; Find the pin-outs of the J1962 connector, since its standard connector albeit with slightly different pin-outs per car type the answer is easily found on google.  Go search it up yourself <img src='http://www.madox.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Second step &#8211; Oscilloscope.  A lovely portable fluke connected to the two CAN bus lines told me the baud rates of each of the two buses.  500kbps and 125kbps respectively.</p>
<p>Third step &#8211; Start sniffing, or at least buy the stuff to do so.  I had wanted to build my own CAN interface board but laziness got the better of me and I bought the cheapest one online I could find from <a href="http://www.qprotos.com/">QProtos</a>.  In hindsight it wasn&#8217;t the best choice but it wasn&#8217;t that bad either.  Coupled with a J1962 cable from <a href="www.obd2cables.com">OBD2Cables.com</a> (only remember them because i&#8217;m still receiving email offers hehe) I had everything I need to start.</p>
<p>Fourth step &#8211; Really start sniffing.  A precaution I took was to set the CAN-USB adaptor to &#8216;listen&#8217; mode only, I didn&#8217;t want to risk the brakes suddenly not working.</p>
<p>A bunch of static tests to start things off nice and slow.  The methodology was simple, start the CAN bus logging then carry out actions on the car at certain times &#8211; turn the blinker, step on the accelerator etc.  All was left to be done was to review the logs to see which bits or bytes changed at those matching times.</p>
<p>Fifth step &#8211; The fun bit!  Dynamic testing!  This time with the same setup as above but with my GPS phone logging simultaneously too.  Oh what fun you can achieve here.</p>
<div id="attachment_23" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.madox.net/blog/wp-content/uploads/2008/11/speed-gps-can.jpg"><img class="size-medium wp-image-23" title="speed-gps-can" src="http://www.madox.net/blog/wp-content/uploads/2008/11/speed-gps-can-300x199.jpg" alt="Speed from GPS vs Speed from CAN bus" width="300" height="199" /></a><p class="wp-caption-text">Speed from GPS vs Speed from CAN bus</p></div>
<p>Anyone familiar with the Australian Design Rules and the laws?  The displayed vehicle speed must not be reported lower than actual, so what most manufacturers do is artificially bump that number up.  Hence you see the almost always consistently higher CAN speed compared to the GPS speed&#8230; Hey I haven&#8217;t even said how many &#8216;speed&#8217; signals are transmitted across the CAN bus&#8230;the &#8216;actual&#8217; (unmodified) one is there too.</p>
<h2>The state of affairs</h2>
<p>As of the end of 2006 (Yes two years ago) I had mapped out &#8230; (in no particular order&#8230;well actually in order of CAN bus ID&#8217;s)</p>
<p>On the HS-CAN</p>
<ul>
<li>Brake Active</li>
<li>RPM</li>
<li>Vehicle Speed</li>
<li>Accelerator Pedal position</li>
<li>Brake Active (Again)</li>
<li>True Vehicle Speed</li>
<li>Gear Position &#8211; Park</li>
<li>Gear Position -Reverse</li>
<li>Gear Position -Drive</li>
<li>1st, 2nd&#8230; etc Gears</li>
<li>Gear Shift</li>
<li>Manual/Tiptronic Selection [Yes I drive an Auto]</li>
<li>Gears again&#8230;</li>
<li>Accelerator Pedal position again&#8230;in a different scaling&#8230;Mazda is strange</li>
<li>Left Front Wheel Speed</li>
<li>Right Front Wheel Speed</li>
<li>Left Rear Wheel Speed</li>
<li>Right Rear Wheel Speed</li>
<li>Steering Wheel Angle (I&#8217;m going to have fun with this one!)</li>
<li>Odometer</li>
</ul>
<p>On the MS-CAN</p>
<ul>
<li>RPM (Retransmitted)</li>
<li>Vehicle Speed (Retransmitted)</li>
<li>Head Unit LCD Display (Oh this will be fun too)</li>
<li>TRIP COMPUTER! Average Speed, Fuel Consumption, Average Fuel Consumption, Distance Remaining</li>
</ul>
<p>Oh I so forgot to rant.  Trip Computer, very nice little pieces of information for driving a car.  Official Mazda Australia line?  Oh our Mazda 3&#8242;s don&#8217;t have this.  All overseas models have it.  All information is already on the car.  The car even has a head unit with all the trip computer LCD displays present (you can see it if you tilt your head).  Infact there&#8217;s a little trick you can do with every Mazda 3 model just prior to mine that you can hold down certain keys on the head unit before starting the car that activates it&#8230; but nooooooooooooo its disabled on mine for what reason I don&#8217;t know&#8230; erm&#8230; rant over.  Guess I have to do a better speedometer and trip meter too.</p>
<p>If anyone was expecting to see the results, you have to wait for Part 2 (or 3)&#8230;does anyone actually want to see?   Or got any questions? mmmm</p>
]]></content:encoded>
			<wfw:commentRss>http://www.madox.net/blog/2008/11/17/reverse-engineering-the-mazda-can-bus-part-1/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
	</channel>
</rss>

