HTML Can Sniffer

HTML Can Sniffer

This is probably the most ridiculous way to reverse engineer something to date… a Chumby, an EasySync CAN Sniffer, PHP and JavaScript… 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].  This means I will have to use the Mazda’s MS-CAN bus only [That's where the fuel/trip computer information is].  Only one problem, I didn’t pay much attention to the MS-CAN bus before and the MS-CAN bus isn’t as interesting as the HS-CAN.

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 ‘door open’ for example on the MS-CAN is a lot hard this way.

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…) it works quite well.

How it works

  • 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.
  • 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.
  • The XML is parsed and is rendered into a table for display, data is refreshed at periodic intervals.
  • 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 ‘byte’ field changes.
  • A keypress monitor allows the user to ‘reset’ the changed background colours.
  • Code attached below if you want to peek at the mess…

How I used it

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 ‘433′ byte ‘0′ change colour, write down what changed, reset fields, open another door/do something else.

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’s because the high beam is displayed on the instrument panel whilst normal headlights doesn’t display/do anything.

Another disappointing thing is that the ‘ass/arse sensor’ (that’s what I call the passenger seat detection gizmo) is only a boolean signal…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 – “Warning, the girl on the passenger seat weighs 87kg, do not go on another date”.

I’ll be updating the new information to the Mazda CAN Bus page in the next couple of days… check back then to see what’s new.

Download cansniffer.zip (There’s still a bug with the timestamp I’m too lazy to fix… disclaimer this is hobby/crappy code :P )

One Response to “Reverse Engineering the Mazda CAN Bus – Part 2”
  1. yeyus says:

    Hi!! from Spain

    I’ve been following your blog for a while, watching all the discovers you have made. Great Job!!!. I have a 2.0 Mazda 3 and I expect to develop a similar project using arduino and arcan http://www.arcan.es/ which is a cheap arduino shield to control can-bus interfaces…

    The info you have released will be very usefull. Thanks

  2.  
Leave a Reply