{"id":545,"date":"2009-10-24T23:03:48","date_gmt":"2009-10-24T13:03:48","guid":{"rendered":"http:\/\/www.madox.net\/blog\/?p=545"},"modified":"2009-10-24T23:03:48","modified_gmt":"2009-10-24T13:03:48","slug":"reverse-engineering-the-mazda-can-bus-%e2%80%93-part-2","status":"publish","type":"post","link":"http:\/\/www.madox.net\/blog\/2009\/10\/24\/reverse-engineering-the-mazda-can-bus-%e2%80%93-part-2\/","title":{"rendered":"Reverse Engineering the Mazda CAN Bus \u2013 Part 2"},"content":{"rendered":"<figure id=\"attachment_546\" aria-describedby=\"caption-attachment-546\" style=\"width: 450px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.madox.net\/blog\/wp-content\/uploads\/2009\/10\/Screenshot-CAN-Bus-Sniffer-Mozilla-Firefox.png\"><img loading=\"lazy\" decoding=\"async\" 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\" srcset=\"http:\/\/www.madox.net\/blog\/wp-content\/uploads\/2009\/10\/Screenshot-CAN-Bus-Sniffer-Mozilla-Firefox-450x421.png 450w, http:\/\/www.madox.net\/blog\/wp-content\/uploads\/2009\/10\/Screenshot-CAN-Bus-Sniffer-Mozilla-Firefox.png 776w\" sizes=\"auto, (max-width: 450px) 85vw, 450px\" \/><\/a><figcaption id=\"caption-attachment-546\" class=\"wp-caption-text\">HTML Can Sniffer<\/figcaption><\/figure>\n<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>\n<p><!--more--><\/p>\n<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].\u00a0 This means I will have to use the Mazda&#8217;s MS-CAN bus only [That&#8217;s where the fuel\/trip computer information is].\u00a0 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>\n<p>So new mission to find out what else is on the MS-CAN bus now.\u00a0 Problem is, the nature of the information on the MS-CAN is different to the HS-CAN.\u00a0 For example, something like Speed on the HS-CAN was pretty easy to decipher from just logging the data then plotting again.\u00a0 Trying to figure out &#8216;door open&#8217; for example on the MS-CAN is a lot hard this way.<\/p>\n<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.\u00a0 All done and tested in 2 hours (lots of copy and pasting&#8230;) it works quite well.<\/p>\n<h2>How it works<\/h2>\n<ul>\n<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>\n<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>\n<li>The XML is parsed and is rendered into a table for display, data is refreshed at periodic intervals.<\/li>\n<li>The Javascript compares the XML values with the already rendered values before updating to detect a change in value.\u00a0 If there is a change, the background of the &#8216;byte&#8217; field changes.<\/li>\n<li>A keypress monitor allows the user to &#8216;reset&#8217; the changed background colours.<\/li>\n<li>Code attached below if you want to peek at the mess&#8230;<\/li>\n<\/ul>\n<h2>How I used it<\/h2>\n<p>Basically sat in the car with the sniffer running and trying various combinations to see which bit\/byte changed.\u00a0 e.g. Run sniffer, open a door, see message &#8216;433&#8217; byte &#8216;0&#8217; change colour, write down what changed, reset fields, open another door\/do something else.<\/p>\n<p>There were a few useful fields that I found\/reconfirmed.\u00a0 Nothing too interesting though and alot is disappointing.\u00a0 For example there is information regarding headlight high beam being on, but not just normal headlights.\u00a0 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>\n<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.\u00a0 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>\n<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>\n<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 :P)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[12,31,15,11],"class_list":["post-545","post","type-post","status-publish","format-standard","hentry","category-engineering","tag-can-bus","tag-chumby","tag-firefox","tag-mazda"],"_links":{"self":[{"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/posts\/545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/comments?post=545"}],"version-history":[{"count":5,"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/posts\/545\/revisions"}],"predecessor-version":[{"id":552,"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/posts\/545\/revisions\/552"}],"wp:attachment":[{"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/media?parent=545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/categories?post=545"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/tags?post=545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}