<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://chadgibbons.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://chadgibbons.com/" rel="alternate" type="text/html" /><updated>2024-10-26T21:48:31+00:00</updated><id>https://chadgibbons.com/feed.xml</id><title type="html">Chad Gibbons’ Blog</title><subtitle>Bicycles, Booze, Cars, and Coding, oh my!</subtitle><entry><title type="html">Migrating to Jekyll</title><link href="https://chadgibbons.com/2019/11/29/migrating-to-jekyll" rel="alternate" type="text/html" title="Migrating to Jekyll" /><published>2019-11-29T00:00:00+00:00</published><updated>2019-11-29T00:00:00+00:00</updated><id>https://chadgibbons.com/2019/11/29/migrating-to-jekyll</id><content type="html" xml:base="https://chadgibbons.com/2019/11/29/migrating-to-jekyll"><![CDATA[<p>After yet another security breach on my Wordpress blog, this time one that all
the great security tools didn’t catch, I’ve decided to migrate to a static
page hosting solution.</p>

<p>I went with <a href="https://help.github.com/en/github/working-with-github-pages/setting-up-a-github-pages-site-with-jekyll">Github Pages using
Jekyll</a>
which is a well-supported solution for this type of thing.</p>

<p>There are only two real downsides, for now:</p>
<ol>
  <li>I lose the abilty for blog comments, but since that was the primary
vector of security breaches, I’m not too sad about that.</li>
  <li>The theme / layouts are pretty ugly by default, so I have some work to do
to get this looking good (not that it ever did).</li>
</ol>

<p>I do like the idea of using markdown to create blog posts, and the standard
github workflow.</p>]]></content><author><name>chadwick</name></author><summary type="html"><![CDATA[After yet another security breach on my Wordpress blog, this time one that all the great security tools didn’t catch, I’ve decided to migrate to a static page hosting solution.]]></summary></entry><entry><title type="html">Case Study: Micro-services using Erlang</title><link href="https://chadgibbons.com/2017/07/15/case-study-micro-services-using-erlang/" rel="alternate" type="text/html" title="Case Study: Micro-services using Erlang" /><published>2017-07-15T16:35:31+00:00</published><updated>2017-07-15T16:35:31+00:00</updated><id>https://chadgibbons.com/2017/07/15/case-study-micro-services-using-erlang</id><content type="html" xml:base="https://chadgibbons.com/2017/07/15/case-study-micro-services-using-erlang/"><![CDATA[<p>At the Erlang User Conference 2017 (EUC17) in Stockholm Sweden, I presented
our experience of how <a href="http://www.alertlogic.com/">Alert Logic</a> moved to a new
micro-services architecture using our preferred programming language:
<a href="http://www.erlang.org">Erlang</a>.</p>

<p><a href="http://www.alertlogic.com/">Alert Logic</a> had been using Erlang for years
before, but we really did not have a holistic platform for building
applications. A small team of us went off and build a new product for the
company, and in doing so build a new application platform using micro-services
patterns and written in the Erlang programming language.</p>

<p>You can watch a recording of the presentation below, as well as review the
<a href="https://speakerdeck.com/dcgibbons/erlang-micro-services-with-all-the-buzzwords">slide deck</a>.</p>

<p><img src="https://www.youtube.com/watch?v=9o-2K-5SaGw&amp;t=1s" alt="" /></p>]]></content><author><name>chadwick</name></author><category term="jobs" /><category term="software development" /><category term="technology" /><category term="architecture" /><category term="best practices" /><category term="erlang" /><category term="micro-services" /><category term="software developmemnt" /><category term="software engineering" /><category term="talks" /><summary type="html"><![CDATA[At the Erlang User Conference 2017 (EUC17) in Stockholm Sweden, I presented our experience of how Alert Logic moved to a new micro-services architecture using our preferred programming language: Erlang.]]></summary></entry><entry><title type="html">Rapid Prototyping with MacroFab, Part 2</title><link href="https://chadgibbons.com/2016/02/06/rapid-prototyping-with-macrofab-part-2/" rel="alternate" type="text/html" title="Rapid Prototyping with MacroFab, Part 2" /><published>2016-02-07T04:55:05+00:00</published><updated>2016-02-07T04:55:05+00:00</updated><id>https://chadgibbons.com/2016/02/06/rapid-prototyping-with-macrofab-part-2</id><content type="html" xml:base="https://chadgibbons.com/2016/02/06/rapid-prototyping-with-macrofab-part-2/"><![CDATA[<p>As I described in <a href="http://chadgibbons.com/2016/02/06/rapid-prototyping-with-macrofab-part-1/">Part
1</a>,
I am using <a href="http://www.macrofab.com/">MacroFab</a> for rapid prototyping of
my <a href="http://chadgibbons.com/2014/01/09/jeep-bot-proof-of-concept-1/">jeepbot</a>
concept project. In this post, I’ll describe the next phase of my project and
how MacroFab has made it easy to get there.</p>

<p>As I thought about what jeepbot should be, the concept evolved into several
different ideas. What I wanted to build first was a control board that
directly controlled a simple relay box, like the one described by <a href="http://www.wranglerforum.com/f202/hoozs-diy-spod-ish-project-1109890.html">Hooz’s DIY
project</a>
post. The idea was to focus on the control circuitry first, rather than the
relay circuitry. The control board would replace a bank of switches, so easily
plug-and-play. This would allow me to fine-tune the design over time, while
retaining a good, simple relay box in the vehicle. I also renamed the project
concept <strong><em><a href="https://github.com/dcgibbons/switchbot">switchbot</a></em></strong> to go with
the idea of being vehicle independent.</p>

<p>For my first board, I designed a circuit that contained a Atmel
<a href="http://www.atmel.com/devices/atmega328p.aspx">ATmega328P</a> micro-controller, a
<a href="http://www.microchip.com/wwwproducts/devices.aspx?dDocName=en010406">MCP2515</a>
CAN controller, a
<a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010405">MCP2551</a>
CAN transceiver, and a <a href="http://www.ti.com/lit/ds/symlink/sn74hc595.pdf">74HC595D 8-bit shift
register</a>. I only designed in
4 switch circuits for this initial board. Each switch circuit is protected by
a <a href="https://www.sparkfun.com/datasheets/Components/LTV-8x6.pdf">LTV816</a>
optocoupler, to isolate the micro-controller’s digital logic from the actual
switches. These output lines can in turn be used to drive other circuits, such
as a relay board.</p>

<p>To round out the board, I added a two-port terminal connector for +12v power
and ground, a two-port terminal connector for CAN high and low connections,
and a DB9 connector for easily interfacing into automobile OBD-II connectors.
I used a 6-port Molex connector for output for power, ground, and the 4 switch
channels. A reset button and a 2x3 header for in-system chip programming
(ICSP) interface to program the ATmega micro-controller was important to
make sure I could download firmware later.</p>

<p>The board also has a simple +12v to +5v power supply regulation circuit and
protection diode, but not with significant automotive transient protection.
That circuitry will likely be needed in future versions.</p>

<p>You can find the Eagle files for this version of the board on github
at <a href="https://github.com/dcgibbons/switchbot/releases/tag/v1.0_alpha">https://github.com/dcgibbons/switchbot/releases/tag/v1.0_alpha</a></p>

<p>Like with my previous board, I used the MacroFab web interface to upload my
<a href="http://www.cadsoftusa.com">Eagle</a> design files. This board had a lot more
parts than my previous one, and my experience with the previous board taught
me I needed to be more careful in double-checking my part selection. Even with
my caution, the engineers at MacroFab found several discrepancies for me
to clarify, mostly with resistor values.</p>

<p>While the board was being produced, I discovered the diode value mistake I
made with my previous board. I found the same mistake in this board, so I
asked MacroFab if it could be replaced - yep! And they did so easily, since
this was before assembly of the board had actually begun.</p>

<p><a href="http://chadgibbons.com/wp-content/uploads/2016/02/IMG_2447.jpg"><img src="/assets/images/IMG_2447-246x300.jpg" alt="IMG_2447" /></a></p>

<p>During the final assembly of the board, MacroFab found the two-port connector
parts I selected for my CAN and power interfaces were wrong for my board
design. I asked them not to populate those connectors as I had many of the
correct ones in my workshop.</p>

<p>MacroFab also found during assembly that the crystal oscillator part I had
selected would not match the pins exactly on my board. The size was
correct, but the orientation was wrong. I recall that selecting the oscillator
part was difficult, so I was not too surprised. A little bit more research
from the parts houses and I found what I thought would be a better part.
MacroFab agreed and ordered it for me. This extra order only added a couple of
days to the overall board assembly time.</p>

<p><a href="http://chadgibbons.com/wp-content/uploads/2016/02/IMG_2448.jpg"><img src="/assets/images/IMG_2448-300x212.jpg" alt="IMG_2448" /></a>A
couple of weeks after ordering, my boards arrived. I ordered two of the boards
this time, as I wanted to be able to leave one in my
<a href="http://www.jeep.com/">Jeep</a> and use another for bench testing. As soon as
they arrived, I hand soldered in the two-port connectors I had (I have a nice
supply of them from <a href="https://www.sparkfun.com/products/8432">SparkFun</a> as
they are so commonly used on Arduino-based boards).</p>

<p>The next step was to power up the board and see what happens. No smoke; it
lives! Without a program downloaded to the micro-controller nothing much
happened, but the solid power-on LED and the all 4 switch LEDs being on
indicated to me that the core of the system was alive.</p>

<p><a href="http://chadgibbons.com/wp-content/uploads/2016/02/IMG_2450.jpg"><img src="/assets/images/IMG_2450-300x225.jpg" alt="IMG_2450" /></a></p>

<p>Next I used an AVR ICSP programmer to download software using the
<a href="https://www.arduino.cc">Arduino</a> IDE, which front-ends the
<a href="http://www.nongnu.org/avrdude/">avrdude</a> tool. I picked the Arduino
blink sketch to see if it would download… success! I do not have an LED on
pin 13 of the ATmega so I couldn’t see the sketch actually running, so next I
dowloadeded my <em>shiftreg</em> test sketch. This sketch will cycle through all 4
switches and leave each one active for a few milliseconds. It will also
display anything it receives over the CAN bus to its own serial output,
although I did not make it easy to show serial output on this board.</p>

<p><a href="http://chadgibbons.com/wp-content/uploads/2016/02/yqbnj.gif"><img src="/assets/images/yqbnj.gif" alt="yqbnj" /></a></p>

<p>Surprisingly to me, not only did the sketch download, it actually worked. The
switch indicator LEDs lit up in turn, and with a meter I could measure the
signal voltage on each output line on the Molex connector. Success!</p>

<p>I now have the basis for real hardware testing in my vehicle. I’ll post a
follow-up on further progress with this project.</p>

<p>The most amazing thing about this experience so far has been the ease of use
of the MacroFab interface, their quick turn-around time, and the pricing. For
these two boards, the price was approximately \$76 each. For a hobbyist, this
pricing puts real low-volume projects in easy each. At higher quantities, the
price drops dramatically. For 1,000 units, for example, pricing approaches $15
a board for this design.</p>

<p>Stay tuned…</p>]]></content><author><name>chadwick</name></author><category term="cars" /><category term="hardware engineering" /><category term="software development" /><category term="technology" /><summary type="html"><![CDATA[As I described in Part 1, I am using MacroFab for rapid prototyping of my jeepbot concept project. In this post, I’ll describe the next phase of my project and how MacroFab has made it easy to get there.]]></summary></entry><entry><title type="html">Rapid Prototyping with MacroFab, Part 1</title><link href="https://chadgibbons.com/2016/02/06/rapid-prototyping-with-macrofab-part-1/" rel="alternate" type="text/html" title="Rapid Prototyping with MacroFab, Part 1" /><published>2016-02-07T01:01:04+00:00</published><updated>2016-02-07T01:01:04+00:00</updated><id>https://chadgibbons.com/2016/02/06/rapid-prototyping-with-macrofab-part-1</id><content type="html" xml:base="https://chadgibbons.com/2016/02/06/rapid-prototyping-with-macrofab-part-1/"><![CDATA[<p>As part of
my <a href="http://chadgibbons.com/2014/01/09/jeep-bot-proof-of-concept-1/">jeepbot</a>
project, I wanted to build some printed circuit boards (PCBs) to test the
concept, try out different designs, and generally just have a real solution. I
learned quickly that going from <a href="http://www.lego.com/en-us/">LEGO</a>-style
building blocks based on <a href="https://www.arduino.cc">Arduino</a> boards to my own
PCB was another learning curve with a lot of unknowns. There are certainly
plenty of tutorials online for designing boards, board houses for building
them, etc., but it certainly wasn’t an easy or inexpensive job for those
learning how to build. As a result, my project languished a bit as both my
<a href="https://www.alertlogic.com/press-releases/alert-logic-launches-cloud-native-vulnerability-and-configuration-management-solution-on-amazon-web-services/">day job became more
demanding</a> (and
amazing, rewarding) and the work effort for this project began to look
larger and more complicated than I had anticipated.</p>

<p>Around this time, a former co-worker <a href="http://www.bizjournals.com/houston/blog/2015/02/founder-of-fast-growing-houston-company-launches.html">founded
MacroFab</a>,
a company geared towards solving the problem of making it easier for small
“makers” (like me!) to “<a href="https://macrofab.com">go from prototype to market faster than ever
before.</a>” <a href="http://www.macrofab.com/">MacroFab’s</a> promise
is to make it fast, easy, and cheap to create prototypes, and then make it
easy to move into the market easily. Macrofab will even manage production and
inventory for you!</p>

<p>While the market support is very intruiging for turning my project into an
actual product, at my project stage I was mostly interested in Macrofab for
the prototyping aspect of it. Given I had almost zero experience designing
schematics, creating boards, or really anything related to creating hardware,
I wanted something easy and inexpensive, as I was sure to be making a lot of
mistakes.</p>

<p>I decided to make a small board to test out everything. I really didn’t know
what to expect when trying to create a real board, so I stuck with something
very simple and easy to test: a +12v to +5v power supply. The design I picked
was simple: a circuit based on a <a href="http://www.onsemi.com/PowerSolutions/product.do?id=NCP1117">NCP1117 linear voltage
regulator</a>, along
with a DC barrel plug for input power, a diode to keep everything safe, a
header for the output signals, and a green power-on LED for good measure.</p>

<p>MacroFab’s interface starts off with you creating a new project, and then
uploading your design either directly from your design tool, such as
<a href="http://www.cadsoftusa.com">CadSoft’s Eagle</a>, or from raw industry standard
file formats. Since I’m using Eagle, that was an easy choice.</p>

<p><a href="http://chadgibbons.com/wp-content/uploads/2016/02/Screen-Shot-2016-02-06-at-3.42.53-PM.png"><img src="/assets/images/Screen-Shot-2016-02-06-at-3.42.53-PM-300x212.png" alt="Screen Shot 2016-02-06 at 3.42.53 PM" /></a>After
your files are uploaded and their system processes them, you are presented
with a view of your PCB and all of its layers. You also start getting a cost
estimate on your design based upon the PCB price, the parts, and MacroFab’s
own labor costs. As you can seen from the screenshot, this board costs less
than $17 for a quantity of 1. Absolutely amazing.</p>

<p><a href="http://chadgibbons.com/wp-content/uploads/2016/02/Screen-Shot-2016-02-06-at-3.43.16-PM.png"><img src="/assets/images/Screen-Shot-2016-02-06-at-3.43.16-PM-300x140.png" alt="Screen Shot 2016-02-06 at 3.43.16 PM" /></a>The
next step in the process is going through your bill of materials. As I learned
later, this is the part of the process where you need to pay the most
attention. MacroFab’s software will do a decent job of finding parts for you
based on your design files. However, not all parts can be found all of the
time and you will need to double-check that the parts match your design
correctly.</p>

<p>One thing that MacroFab has done is a huge benefit here: they have their own
house parts, and an <a href="https://github.com/MacroFab/EDALibraries">Eagle library</a>
to make selecting them easy. For common things such as resistors, capacitors,
LEDs, common micro-controllers, headers, etc. these are a slam-dunk. Not only
are the parts guaranteed to be on-hand, they’re usually a lot cheaper, too.
And for someone like me, I’m not particularly interested in the nuances of
picking the absolute “best” part available; I want good-enough, available,
cheap, and easy. Are there better LEDs than the ones in MacroFab’s inventory?
Maybe, and you can get them if you want, but I’m not sure why I would spend
any time looking for them. Can you tell I’m not a hardware engineer?</p>

<p>The final step in the MacroFab interface before ordering is to review the
placement of the parts you’ve selected. Here’s your final chance to review,
and it gives you a visual indication of how the parts will be placed on the
board. It’s pretty easy to see if you’ve picked a through-hole part instead of
a surface-mount, for example, so this step is amazing valuable and easy.</p>

<p>Finally, you order your part and MacroFab’s operations take over. Within a day
or two of submitting your order, MacroFab’s engineers do a sanity check on
your design. In my case, they wanted to verify that I had the right resistor
and diode values in my design - I said yes (which later turned out to be
wrong!) - and off they went to producing the board.</p>

<p>MacroFab doesn’t create its own PCBs - that’s a cut-throat business with
little margin - so they send out for PCBs from other vendors. At the same
time, they order any parts they might need for your design if they do not
already have the parts in stock. Once everything is in stock, they do the
final assembly of the board in house. With all three of the boards I have had
them build so far, there have been little issues at this stage of the game,
all related to my own mistakes.</p>

<p>In this case, the DC power plug part I picked had the wrong type of
through-hole connectors. Whoops! As a newbie, I didn’t have enough attention
to detail when I was selecting that part (MacroFab’s interface couldn’t find
the right one for me automatically). No matter, I had a bunch of those in my
workshop at the house, so I asked them to skip placement of the part.</p>

<p><a href="http://chadgibbons.com/wp-content/uploads/2016/02/IMG_2365.jpg"><img src="/assets/images/IMG_2365-300x210.jpg" alt="IMG_2365" /></a>About
two weeks (during the busy holiday season, no less!) after I submitted my
order, my board arrived. Included were the spare parts from my order and the
assembled board itself. How exciting, my first PCB ever! As someone who
started out with electronics and hardware as a kid, but quickly moved to
software, this was hugely satisfying and made me wish I had done it decades
ago.</p>

<p>You’ll notice the couple of hand-solder marks on the outline for the DC barrel
jack that I made. It turns out I didn’t have the right part in my workshop
after all, so I just soldered some wire leads to the pins to test everything
out. And, it didn’t work! Puzzled, but not surprised, I did some quick
analysis. It turns out my diode was not the right voltage rating. Instead of a
maximum of 100v, it had a pass-through voltage of 100v instead of 12v…
whoops!</p>

<p>Once I bypassed that diode, the circuit worked great, except for my LED not
lighting up. I quickly found that I had selected a 150K Ω resistor instead of
the 150 Ω resistor I needed. MacroFab actually caught this mistake, but I told
them the part was the right one.
<a href="https://en.wikipedia.org/wiki/D%27oh!">D’oh!</a></p>

<p>Regardless, my first experiment was a success. <em>For less than $20
delivered</em>, I had my first PCB design built and I learned a great deal
about the process. All of which made it much easier to do my next project, and
the goal of all of this - the intelligent switching board for my
<a href="http://www.jeep.com">Jeep</a>. See <a href="http://chadgibbons.com/2016/02/06/rapid-prototyping-with-macrofab-part-2/">part
2</a>
for more details on the next phase.</p>]]></content><author><name>chadwick</name></author><category term="cars" /><category term="fun" /><category term="hardware engineering" /><category term="technology" /><summary type="html"><![CDATA[As part of my jeepbot project, I wanted to build some printed circuit boards (PCBs) to test the concept, try out different designs, and generally just have a real solution. I learned quickly that going from LEGO-style building blocks based on Arduino boards to my own PCB was another learning curve with a lot of unknowns. There are certainly plenty of tutorials online for designing boards, board houses for building them, etc., but it certainly wasn’t an easy or inexpensive job for those learning how to build. As a result, my project languished a bit as both my day job became more demanding (and amazing, rewarding) and the work effort for this project began to look larger and more complicated than I had anticipated.]]></summary></entry><entry><title type="html">CAN Bus Hacking with the Arduino and Raspberry Pi</title><link href="https://chadgibbons.com/2016/01/08/can-bus-hacking-with-the-arduino-and-raspberry-pi/" rel="alternate" type="text/html" title="CAN Bus Hacking with the Arduino and Raspberry Pi" /><published>2016-01-09T05:03:33+00:00</published><updated>2016-01-09T05:03:33+00:00</updated><id>https://chadgibbons.com/2016/01/08/can-bus-hacking-with-the-arduino-and-raspberry-pi</id><content type="html" xml:base="https://chadgibbons.com/2016/01/08/can-bus-hacking-with-the-arduino-and-raspberry-pi/"><![CDATA[<p>In December of 2013, I published a set of videos on YouTube discussing how to
do CAN bus hacking using an Arduino and/or Raspberry Pi. These videos were
made in conjunction with my Jeep hacking projects.</p>

<p>Several viewers have asked for a little bit more information on getting an
Arduino and Raspberry Pi to talk to one another over a CAN bus, so I thought
I’d provide a bit of written information here to accompany the videos. In
addition, two years of time have provided some improvements that make
everything easier.</p>

<p>For both the Arduino and the Raspberry Pi, I used
daughter boards that use Microchip’s
<a href="http://www.microchip.com/wwwproducts/devices.aspx?dDocName=en010406">MCP2515</a>
CAN controller and
<a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010405">MCP2551</a>
CAN transceiver. These are extremely common integrated circuits for CAN and
are great to integrate with as they use an Serial Peripheral Interface (SPI).</p>

<h4 id="the-videos">The Videos</h4>

<p><img src="https://www.youtube.com/watch?v=f5lvxXVYxKY" alt="" /></p>

<p><img src="https://www.youtube.com/watch?v=xClkZThopSk" alt="" /></p>

<h4 id="the-can-bus">The CAN Bus</h4>

<p>A CAN bus has to be properly terminated on each end of the bus. The easiest
way to do this on a bench is using a breadboard. Use two 120 Ω resistors on
each end of one of the power rails to terminate the bus properly. You can then
connect your nodes to any location within the power rail and have them join
the bus properly.</p>

<p>Be sure to create a twisted pair out of each set of wires coming from each
node. CAN bus is highly resilient to electrical noise when each node follows
certain rules, and twisted pairs of wires is one of those rules.</p>

<p><img src="/assets/images/IMG_2344-1024x768.jpg" alt="A CAN bus setup on a breadboard" />
<em>A CAN bus setup on a breadboard</em></p>

<h4 id="the-arduino-setup">The Arduino Setup</h4>

<p>Sparkfun sells a <a href="https://www.sparkfun.com/products/13262">CAN bus shield</a>
designed by <a href="http://skpang.co.uk/">SK Pang</a>. This shield is great for
developing automotive-focused applications, and is extremely easy to use from
a software standpoint. Once built, the shield plugs into an Arduino with no
further configuration.</p>

<p>For software, the following should be downloaded:</p>

<ol>
  <li>My AVRDebug library - https://github.com/dcgibbons/AVRDebug</li>
  <li>My “hello, world” application - https://github.com/dcgibbons/CANBusHello</li>
  <li>The library for the Sparkfun / SK Pang shield - https://github.com/sparkfun/SparkFun_CAN-Bus_Arduino_Library</li>
</ol>

<p>Once built and downloaded, the project will broadcast a message to the CAN bus
every 500ms. The message will contain an ASCII string value of a monotonically
increasing integer value.</p>

<p>If you run the project without another node connected to the CAN bus, expect
to start seeing errors after a few messages are queued up. The sender requires
another node on the network to acknowledge the message electrically. This can
trip you up if you are first starting out with the CAN bus as it is
non-obvious why you might be getting an error.</p>

<h4 id="the-raspberry-pi-setup">The Raspberry Pi Setup</h4>

<p>The easiest way to get CAN support on your Raspberry Pi is to buy a daughter
board from SK Pang:
the<a href="http://skpang.co.uk/catalog/pican-canbus-board-for-raspberry-pi-p-1196.html">PICAN</a>
board. You can build your own configuration using mcp2515 and mcp2551 ICs, but
for the price the PICAN is an easy bet.</p>

<p>Today the Raspberry Pi setup is much easier than ever before. Pick the
2015-02-16 or newer version of Raspian and you will not have to compile any
kernel modules.</p>

<p>See this <a href="http://skpang.co.uk/blog/archives/1165">blog post</a> on SK Pang
site on setting up your complete system.</p>

<p>On the RPi, the regular SK Pang setup they have documented works great. On
mine, the end of my /boot/config.txt looks like:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dtparam=spi=on dtoverlay=mcp2515-can0-overlay,oscillator=16000000,interrupt=25 dtoverlay=spi-bcm2835-overlay dtoverlay=spi-dma-overlay
</code></pre></div></div>

<p>and then my /etc/network/interfaces file looks like:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>auto can0 iface can0 inet manual pre-up ip link set $IFACE type can bitrate 500000 listen-only off triple-sampling on up /sbin/ifconfig $IFACE up down /sbin/ifconfig $IFACE down
</code></pre></div></div>

<p>The ip command can give you a big clue on state if you use this command:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>root@raspberrypi:~# ip -details -statistics link show can0 
3: can0: &lt;NOARP,UP,LOWER_UP,ECHO&gt; mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 10 
link/can 
can &lt;TRIPLE-SAMPLING&gt;
**state ERROR-ACTIVE** 
restart-ms 0 bitrate 500000 
sample-point 0.875 tq 125 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1 
mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
**clock 8000000** re-started bus-errors arbit-lost error-warn error-pass bus-off 
</code></pre></div></div>

<p>The couple of things I bolded are key. The clock should be 1/2 of what the
oscillator setting in config.txt is (weird quirk). The state is the actual
MCP2515 state - so error-active is what you usually want to see. Error-passive
or Bus-off are bad. See the mcp2515 datasheet for details there.</p>

<p>You’ll want can-utils downloaded and
installed: <a href="https://github.com/linux-can/can-utils">https://github.com/linux-can/can-utils</a></p>

<p>Then, if you run the Arduinoo project so it’s sending data every 500
ms, and then run this command on the RPi, you should see some similar output:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pi@raspberrypi ~ $ candump -t a -c -c -a can0 
(1452184714.419422) can0 1FF [8] 31 34 32 35 33 00 00 00 '14253...' 
(1452184714.939332) can0 1FF [8] 31 34 32 35 34 00 00 00 '14254...'
(1452184715.459257) can0 1FF [8] 31 34 32 35 35 00 00 00 '14255...'
</code></pre></div></div>

<p>You can use the can-utils for just about everything. cansend and canplayer are
useful for sending messages, candump and cansniffer are the two used for
watching data (cansniffer is especially awesome for figuring out what’s really
happening). If you want to write custom software that uses CAN on the RPi,
then you can use these as examples. It’s effectively just using the socket
system calls.</p>

<p>So that’s pretty much it. You have to have the bus speed match, you have to
have the correct wiring, but otherwise that’s all there is to it. I’ve got a
setup with an Arduino as shown below, the RPi as shown below,
another RPi with a different CAN board (still mcp25xx), and a breadboard cased
ATMEGA setup without the Arduino hardware. All works great.</p>]]></content><author><name>chadwick</name></author><category term="cars" /><category term="fun" /><category term="software development" /><category term="technology" /><category term="arduino" /><category term="can-bus" /><category term="hacking" /><category term="raspbnerry pi" /><category term="rpi" /><summary type="html"><![CDATA[In December of 2013, I published a set of videos on YouTube discussing how to do CAN bus hacking using an Arduino and/or Raspberry Pi. These videos were made in conjunction with my Jeep hacking projects.]]></summary></entry><entry><title type="html">Epic Bicycle Rides - Corona Pass in Winter</title><link href="https://chadgibbons.com/2016/01/08/epic-bicycle-rides-corona-pass-in-winter/" rel="alternate" type="text/html" title="Epic Bicycle Rides - Corona Pass in Winter" /><published>2016-01-09T03:06:08+00:00</published><updated>2016-01-09T03:06:08+00:00</updated><id>https://chadgibbons.com/2016/01/08/epic-bicycle-rides-corona-pass-in-winter</id><content type="html" xml:base="https://chadgibbons.com/2016/01/08/epic-bicycle-rides-corona-pass-in-winter/"><![CDATA[<p>I biked up Corona Pass on 1/1/2016.</p>

<h4 id="whats-corona-pass">What’s Corona Pass?</h4>

<p><a href="https://en.wikipedia.org/wiki/Rollins_Pass">Corona Pass</a>, also known as
Rollins Pass, is a high-altitude mountain pass in north-central Colorado,
between the towns of <a href="http://www.playwinterpark.com">Winter Park</a> and
Nederland. Part of the Moffat Road, Rollins Pass was the first railroad
passage over the Rocky Mountains, before the <a href="https://en.wikipedia.org/wiki/Moffat_Tunnel">Moffat
tunnel</a> was opened in 1928.
The pass was used by railroad traffic from the early 1900s through 1928, and
then thereafter has been used mostly as an scenic automotive drive.</p>

<p>In the summertime, I bicycle up Corona Pass several times a season. It’s great
to get above the tree-line on a bicycle, and the pass road itself has access
to many great single-track trails such as <a href="http://www.mtbproject.com/trail/4063693">Broken
Thumb</a>, Twisted Ankle, and <a href="http://www.mtbproject.com/trail/7007093/rogers-pass">Rogers
Pass</a>.</p>

<p>In the winter, the road turns into a snowmobile heaven.  The<a href="http://www.grandadventures.com">Grand
Adventures</a> company has the USFS permits for
grooming much of the trails in the Fraser Valley, and Corona Pass is one of
the major roads for their service (and for public use as well). As a result,
it turns into a great road for fat biking in the winter. I’ve ridden this pass
in Winter a couple of times each season, and it’s always been a blast.</p>

<h4 id="the-plan">The Plan</h4>

<p>This ride had been my New Year’s Day plan for a while, but it almost didn’t
happen. It got down to -20ºF overnight at my place, and in the morning it
wasn’t really warming up. But, thanks to some weather sorcery, it was actually
warmer closer to the mountains. I left 90 minutes later than planned - at
11:30am it was -11ºF at my place, and 15 miles away at the start of my ride it
was a whopping 8ºF. Cold, but certainly bearable, especially on such a bright
sunny day.</p>

<p><img src="/assets/images/IMG_2321-1024x768.jpg" alt="IMG_2321" />
<em>The Destination</em></p>

<p>The road was in great shape on the way up - groomed, snowmobiled, and packed
in well.</p>

<p>On the way down, enough snowmobile traffic had come up during my ride that the
snow was really chewed up. In some respects that made for a better descent, as
I had to pedal just enough to keep my heart rate up and that kept me from
freezing as much.</p>

<p><a href="https://www.strava.com/activities/460956772">The ride up</a> took 2hrs 50min to
cover 9 miles, with 2200 ft elevation gain with a 4.4% average grade. The
descent took just an hour.</p>

<p>This was the first time I made it all the way to the top of where the
snowmobile traffic goes. What a great adventure, and great way to start 2016.</p>

<h4 id="scenes-along-the-way">Scenes Along the Way</h4>

<p><img src="/assets/images/IMG_2294-768x1024.jpg" alt="IMG_2294" /> 
After a 3/4 mile climb over a rough snowmobile trafficked hill from the
parking lot, I wound up on
Corona Pass road. The Grand Adventures snowmobile rental company grooms the
main road regularly. It’s a gentle grade (~3-5%) and a relatively easy climb
up. The road closed sign is because the Needle Eye tunnel, on the Front Range
side, collapsed years ago and they haven’t re-opened it yet. You can go all
the way up from Nederland, and all the way up from Winter Park, but you can’t
drive over - non-motorized traffic can make it over, though.</p>

<p><img src="/assets/images/IMG_2296-768x1024.jpg" alt="IMG_2296" />
<em>Only light tracks left on the super packed snow.</em></p>

<p><img src="/assets/images/IMG_2300-1024x1024.jpg" alt="IMG_2300" />
<em>First big break with the treeline now closeby. Rogers Pass is in view, and
Riflesight Notch is just ahead.</em></p>

<p><img src="/assets/images/IMG_2301-768x1024.jpg" alt="IMG_2301" />
<em>The famous Riflesight Notch railroad trestle. When the railroad ran, the
tracks would circle down the hill and then come out underneath the trestle
from a tunnel, hence the name.</em></p>

<p><img src="/assets/images/IMG_2322-1024x768.jpg" alt="IMG_2322" />
<em>A friendly snowmobiler took my picture while next to the trestle. Mt. Epworth and my destination is
just behind me.</em></p>

<p><img src="/assets/images/IMG_2302-1024x768.jpg" alt="IMG_2302" />
<em>Welcome to the tundra. I MADE IT! This is as high as I’ve been in in the
winter on any of my rides up here. Rollins Pass is about 2-3 miles in the
distance, but the road isn’t groomed in the winter (enough for me to make it
on a bike, anyway).</em></p>

<p><img src="/assets/images/IMG_2305-768x1024.jpg" alt="IMG_2305" />
<em>I’m still alive! Despite being very, very cold, there was no wind today -
absolutely none. It was awesome up top.</em></p>

<p><img src="/assets/images/IMG_2304-1024x259.jpg" alt="IMG_2304" />
<em>Gratuitous pano…</em></p>

<p><img src="/assets/images/IMG_2303-1024x768.jpg" alt="IMG_2303" />
<em>Looking down towards the Fraser valley from the top. You can see Fraser and
Tabernash (my place!) far below.</em></p>

<p><img src="/assets/images/IMG_2306-1024x768.jpg" alt="IMG_2306" />
<em>And there’s the Continental Divide! Just a hundred yards or so away. On the
otherside is Nederland and then Boulder.</em></p>

<p><img src="/assets/images/IMG_2309-1024x768.jpg" alt="IMG_2309" />
<em>Looking towards Winter Park we can see the ski resort and the Riflesight Notch
railroad trestle where I just came from.</em></p>

<p><img src="/assets/images/IMG_2311-1024x768.jpg" alt="IMG_2311" />
<em>Looking back towards the North we can see Mt. Epworth and Rollins Pass in the
distance. If you look closely, you can see snowmobile tracks the more advanced
riders have made over to that area.</em></p>

<p><img src="/assets/images/IMG_2307-1024x768.jpg" alt="IMG_2307" />
<em>Further down the hill. In the summer, this rock is just above the main road.
The snowmobiles all wind up here for the scenic view.</em></p>

<p><img src="/assets/images/IMG_2317-768x1024.jpg" alt="IMG_2317" />
<em>11,500 ft!</em></p>

<p><img src="/assets/images/IMG_2318-1024x768.jpg" alt="IMG_2318" />
<em>About to descend… this hill, down towards Corona Bowl, was actually too
steep to ride up, so I hiked up. Coming down, a minute or so after this shot
was taking, I built up too much speed and had a spectacularly fluffy powder
crash. A little less air pressure in the tires would have helped
that…</em></p>

<p><img src="/assets/images/IMG_2319-1024x768.jpg" alt="IMG_2319" />
<em>Back down at the Riflesight Notch railroad trestle… still early in the
season so it is visible.</em></p>]]></content><author><name>chadwick</name></author><category term="cycling" /><category term="fun" /><category term="sports" /><category term="adventure" /><category term="bicycle" /><category term="bicycling" /><category term="colorado" /><category term="epic" /><category term="fat bike" /><category term="fatboy" /><category term="mountains" /><category term="ride the rockies" /><category term="snow" /><category term="specialized" /><category term="training" /><category term="USFS" /><summary type="html"><![CDATA[I biked up Corona Pass on 1/1/2016.]]></summary></entry><entry><title type="html">Feature Survey - Intelligent Accessory Controller</title><link href="https://chadgibbons.com/2014/01/26/feature-survey-intelligent-accessory-controller/" rel="alternate" type="text/html" title="Feature Survey - Intelligent Accessory Controller" /><published>2014-01-26T20:53:12+00:00</published><updated>2014-01-26T20:53:12+00:00</updated><id>https://chadgibbons.com/2014/01/26/feature-survey-intelligent-accessory-controller</id><content type="html" xml:base="https://chadgibbons.com/2014/01/26/feature-survey-intelligent-accessory-controller/"><![CDATA[<p>If you saw my post about hacking the <a href="http://chadgibbons.com/2013/12/29/hacking-the-jeep-interior-can-bus/">CAN-Interior bus of a
JK</a>, you
noticed my comments about building an intelligent accessory switching system.
I’m <a href="http://chadgibbons.com/2014/01/09/jeep-bot-proof-of-concept-1/">pretty far
along</a> with
that, and would love to get some feedback from the community on features
they’d like to see.</p>

<p>Right now my plan is to build something, release it all with open-source and
open-hardware so people can build their own, but there’s been enough interest
for people who would like to have one built for themselves that I made the
following survey. If you have a moment, I would really appreciate your
feedback.</p>

<p>Once the survey is all done, I’ll post the results here too so everyone can
see the data.</p>

<p>And if you aren’t sure exactly what I’m talking about - it’s effectively a
standard relay box in your engine bay, but instead of <em>just</em> toggle switches,
it’s smart and listens to your car’s computers and can activate switches when
lights go on/off, high-beams, blinkers, ignition - whatever we can think of.</p>

<p>The link to the survery is here:
<a href="https://www.surveymonkey.com/s/LKMHTBG">https://www.surveymonkey.com/s/LKMHTBG</a></p>]]></content><author><name>chadwick</name></author><category term="cars" /><summary type="html"><![CDATA[If you saw my post about hacking the CAN-Interior bus of a JK, you noticed my comments about building an intelligent accessory switching system. I’m pretty far along with that, and would love to get some feedback from the community on features they’d like to see.]]></summary></entry><entry><title type="html">Jeep Bot - Proof of Concept #1</title><link href="https://chadgibbons.com/2014/01/09/jeep-bot-proof-of-concept-1/" rel="alternate" type="text/html" title="Jeep Bot - Proof of Concept #1" /><published>2014-01-10T05:17:10+00:00</published><updated>2014-01-10T05:17:10+00:00</updated><id>https://chadgibbons.com/2014/01/09/jeep-bot-proof-of-concept-1</id><content type="html" xml:base="https://chadgibbons.com/2014/01/09/jeep-bot-proof-of-concept-1/"><![CDATA[<p>I finished the 1st proof-of-concept for using the CAN-Bus data to control
auxiliary relays. It worked great. Attached is a block diagram of what I used,
and a longish video of how the testing went.</p>

<p><img src="/assets/images/jeep_bot_poc1.png" alt="" /> Jeep Bot Block Diagram</p>

<p>If you want to skip all the bench testing, the actual in-car testing happens
at the 11:15 mark of the video.</p>

<p><img src="https://www.youtube.com/watch?v=v64EYqzys0Q" alt="" /></p>

<p>Code for the demo can be found
at <a href="https://github.com/dcgibbons/jeepbot/tree/poc1" title="https://github.com/dcgibbons/jeepbot/tree/poc1">https://github.com/dcgibbons/jeepbot/tree/poc1</a></p>

<p>A few hours after I finished, a bluetooth-low-energy board I ordered showed
up. The next step will be to throw that on there so that I can use the
smartphone to configure each switch and optionally control them by hand.</p>

<p>Each switch will have the following different possible control states:</p>

<ul>
  <li>always on</li>
  <li>manual only</li>
  <li>on when interior lights are on</li>
  <li>on when high-beams are on</li>
</ul>

<p>Right after that, I’ll start working on a prototype PCB and housing so I can
start testing real versions of this system.</p>

<p>I’ll post the design, schematics and code in progress on my blog so anyone can
offer feedback as it gets built.</p>]]></content><author><name>chadwick</name></author><category term="cars" /><category term="software development" /><category term="technology" /><category term="automotive" /><category term="auxiliary" /><category term="can" /><category term="can-bus" /><category term="car" /><category term="hacking" /><category term="jeep" /><category term="relay" /><category term="switches" /><category term="wrangler" /><summary type="html"><![CDATA[I finished the 1st proof-of-concept for using the CAN-Bus data to control auxiliary relays. It worked great. Attached is a block diagram of what I used, and a longish video of how the testing went.]]></summary></entry><entry><title type="html">Hacking the Jeep Interior CAN-Bus</title><link href="https://chadgibbons.com/2013/12/29/hacking-the-jeep-interior-can-bus/" rel="alternate" type="text/html" title="Hacking the Jeep Interior CAN-Bus" /><published>2013-12-29T18:24:45+00:00</published><updated>2013-12-29T18:24:45+00:00</updated><id>https://chadgibbons.com/2013/12/29/hacking-the-jeep-interior-can-bus</id><content type="html" xml:base="https://chadgibbons.com/2013/12/29/hacking-the-jeep-interior-can-bus/"><![CDATA[<p><img src="/assets/images/jeep_hacked.jpg" alt="Hacked" />
<em>The Jeep’s Electronic Vehicle Information Center (EVIC) Displays a Custom Message</em></p>

<p>I have a <a href="http://www.jeep.com/en/2012/wrangler_unlimited/">2012 Jeep Wrangler Unlimited</a>
and have a few projects where I wanted to integrate closely with
the vehicle’s electronics. Instead of tapping into the final wiring of the
car, I wanted to leverage the vehicle’s own computers to tell my accessories
what to do. The end goal being a much tighter and seamless integration, and
much less modification to the wiring of the vehicle.</p>

<p>Modern automobiles use a technology called a <a href="http://en.wikipedia.org/wiki/CAN_bus">Controller Area Network</a>, or
CAN-Bus, to communicate between the different computers within the vehicle.
The use of this technology greatly simplifies the wiring requirements within
the vehicle as a large number of components can share a single twisted-pair
wiring harness.</p>

<p>There are actually three separate CAN bus systems used in the vehicle: the
CAN-Interior (also known as CAN Interior High Speed/IHS), the CAN-C and the
Diagnostic CAN-C. The CAN-Interior bus is used for communication between the
interior modules of the vehicle, such as the dashboard and radio and runs at
125 Kbps. The CAN-C bus is used by the power train components and runs at 500
Kbps. Finally, there is the Diagnostic CAN-C which also runs at 500 Kbps.</p>

<p>The Diagnostic CAN-C bus is used to talk to a gateway computer, the Totally
Integrated Power Module or TIPM. This gateway implements all of the logic
needed for onboard diagnostics, and communicates to the other two buses as
needed. One effect of this implementation is that data from the other buses is
not easily obtained via the data link connector (a.k.a the
<a href="http://en.wikipedia.org/wiki/On-board_diagnostics">ODB-II</a> port) underneath 
the dash. While a tremendous amount of
information is available via the diagnostic bus, it isn’t easy to hack or
obtain without getting official documentation from the manufacturer directly.</p>

<p>I came across <a href="http://canbushack.com" title="canbushack.com">canbushack.com</a>
when I was thinking about looking at the CAN-interior bus and was happy to see
much of the information I was after is on that bus. Unfortunately, I also
found that the implementation has changed quite a bit from the time most of
the work was done on that site versus what is in my Jeep today.</p>

<p><img src="/assets/images/jeep_custom_c2_harness.jpg" alt="Radio C2" />
<em>Custom Wiring Harness using the Radio C2 Connector</em></p>

<p>The easiest way to access the CAN-interior bus is the <a href="http://connectors.dcctools.com/details.htm?id=77646" title="Mopar
68032281AA - Radio C2">radio C2
harness.</a>I built a pigtail wiring harness by buying a
couple of aftermarket radio wiring harnesses, linking them together, and
splicing in a pair of wires for the CAN-H and CAN-L connectors. By making a
custom pigtail like this I avoided having to alter any of the OEM wiring
making for both easy removal and a lower risk of screwing up something.</p>

<p>I originally used an Arduino Uno micro-controller board and a <a href="https://www.sparkfun.com/products/10039" title="CAN-Bus Shield for Arduino">CAN interface
shield</a>
from <a href="http://www.sparkfun.com" title="SparkFun">SparkFun</a> and <a href="http://skpang.co.uk/catalog/arduino-canbus-shield-with-usd-card-holder-p-706.html" title="Arduino CAN-Bus Shield">SK Pang
Electronics</a>. This platform is a prototype for what I will
eventually use as the final production solution for my projects, but I quickly
found that analyzing and hacking the vehicle’s CAN-Interior bus was too
tedious with that solution, for two primary reasons: a) I had to write code to
test any hypothesis, and b) I had to be physically connected to the Arduino
with my laptop, in the car, in the cold of winter.</p>

<p><img src="/assets/images/raspberry_pi_with_canbus_board.jpg" alt="RPi" />
<em>Raspberry Pi with CAN Interface Board</em></p>

<p>To solve both issues, I configured a Raspberry Pi system with a CAN interface
board made specifically for it by <a href="http://skpang.co.uk/catalog/pican-canbus-board-for-raspberry-pi-p-1196.html" title="PICAN Board for Raspberry Pi">SK Pang
Electronics</a> and a<a href="http://www.amazon.com/gp/product/B003MTTJOY/ref=oh_details_o05_s01_i00" title="Edimax EW-7811Un 150 Mbps Wireless 11n Nano Size USB Adapter">USB WiFi
dongle</a> so I could
leave the system in the vehicle and login to it from the comfort of my living
room. Since the RPi is a temporary research solution only, I only placed
into the glovebox, connected the CAN-H and CAN-L wires, and used a USB power
supply directly from the vehicle’s 12v auxiliary power port.</p>

<p>Configuring the Raspberry Pi to communicate with the CAN Bus is unfortunately
non-trivial, and I will cover that in another post.</p>

<p>What’s great about using Linux for CAN-bus hacking is the plethora of great
tools available.
The <a href="https://gitorious.org/linux-can/can-utils" title="can-utils
package">can-utils</a> package in particular contains the command-line tools I used to
analyze CAN bus messages and generate my own.</p>

<p>The very first thing to do is to look at the traffic on the bus using the
<code class="language-plaintext highlighter-rouge">candump</code> utility. This utility does exactly what it sounds like - dumps all
of the traffic it sees on the bus to your terminal or to a file. When I first
tried <code class="language-plaintext highlighter-rouge">candump</code> on the CAN-Interior bus of the Jeep, I started to see data
like this:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>id:0x402 len:8 rtr:0 data:0xfe 0x02 0x3f 0xff 0xff 0xff 0xff 0xff
id:0x3e6 len:3 rtr:0 data:0x0b 0x11 0x1e
id:0x1e7 len:8 rtr:0 data:0x70 0x00 0x00 0x00 0x00 0x00 0x00 0x00
id:0x208 len:7 rtr:0 data:0x00 0x00 0x6d 0x5a 0x1e 0x01 0x2c
id:0x2d2 len:3 rtr:0 data:0x00 0x33 0x00
id:0x2dd len:4 rtr:0 data:0x05 0x00 0x00 0x00
id:0x2df len:8 rtr:0 data:0x10 0x04 0x03 0xe8 0x0f 0xa0 0x09 0xbf
id:0x286 len:6 rtr:0 data:0x03 0x38 0x00 0x00 0x00 0x00
id:0x348 len:8 rtr:0 data:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
id:0x2d2 len:3 rtr:0 data:0x00 0x33 0x00
id:0x2eb len:4 rtr:0 data:0x1e 0x00 0x64 0xee
id:0x2ce len:8 rtr:0 data:0xff 0xff 0x00 0x00 0x00 0x00 0x00 0x00
id:0x2b0 len:4 rtr:0 data:0x02 0x00 0x00 0x00
id:0x211 len:8 rtr:0 data:0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
id:0x19f len:8 rtr:0 data:0x01 0xff 0x00 0xff 0xff 0xff 0xff 0x00
id:0x370 len:8 rtr:0 data:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
id:0x214 len:7 rtr:0 data:0x04 0x0d 0xba 0x00 0x14 0xb4 0x00
id:0x286 len:6 rtr:0 data:0x03 0x38 0xc0 0x00 0x00 0x00
id:0x2eb len:4 rtr:0 data:0x1e 0x00 0x64 0xef
id:0x2ce len:8 rtr:0 data:0xff 0xff 0x00 0x00 0x00 0x00 0x00 0x00
id:0x211 len:8 rtr:0 data:0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff
</code></pre></div></div>

<p>What a mess! That amount of data flashed across the screen in less than a
quarter second and began to repeat in long cycles. It was very difficult to
look at such a stream of data and detect when changes occurred based upon user
action. Luckily, the <code class="language-plaintext highlighter-rouge">can-utils</code> package includes another awesome tool called
<code class="language-plaintext highlighter-rouge">cansniffer</code> that can help with that very problem.</p>

<p>When you run <code class="language-plaintext highlighter-rouge">cansniffer</code>, it looks at the traffic for specific message ids
and begins to filter out repeating messages that do not change. After a few
seconds of startup time, the Jeep is left with the following changing data
while in accessory mode:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>214 04 12 70 00 13 11 00 ..p....
217 63 78 07 40 6b fd cx.@k.
219 01 47 35 43 4c 32 37 31 .G5CL271
3e6 00 0d 12 ...
</code></pre></div></div>

<p>It was clear from watching cansniffer what some of this data was.</p>

<p>Message Id <code class="language-plaintext highlighter-rouge">$219</code> is the vehicle identification number repeated over and over.
The first byte of the message is the message #, <code class="language-plaintext highlighter-rouge">$00</code> through <code class="language-plaintext highlighter-rouge">$04</code> with the
VIN split across each.</p>

<p>Message Id <code class="language-plaintext highlighter-rouge">$3e6</code> is a clock of the hours, minutes and seconds since the
vehicle was turned on.</p>

<p>I was then able to operate switches in the vehicle and discover the following
messages in short order:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>244 81 00 39 C3 80 # Driver's door open, byte 0
244 80 00 39 C3 80 # Driver's door closed, byte 0
208 01 22 6d 5a 1e 01 2c # Left blinker on, byte 0
208 00 22 6d 6a 1e 01 2c # Left blinker off, byte 0
208 02 22 6d 5a 1e 01 2c # Right blinker on, byte 0
208 00 22 6d 6a 1e 01 2c # Right blinker off, byte 0
1e1 00 00 10 65 00 00 00 00 # Steering wheel position, bytes 3 &amp; 4
2e0 00 01 47 21 ff ff 0c # Brake pedal depressed, byte 4
2e0 00 01 47 20 ff ff 0c # Brake pedal released, byte 4
2e7 84 1c 00 00 00 00 87 # Parking brake on, byte 0
2e7 04 1c 00 00 00 00 87 # Parking brake off, byte 0
292 00 49 33 00 00 48 28 # Throttle pressed, byte 3
2a8 00 01 00 00 00 00 # Windshield wipers, byte 3
2e5 03 # Rear wiper
2d2 01 06 00 # 4WD-HI
2d2 04 04 00 # 4WD-LO
2d2 00 03 00 # 2WD
</code></pre></div></div>

<p>Some of the data in each message is immediately apparent and others will take
some more analysis to figure out what each byte represents. I was particularly
surprised to see that the steering wheel movement t generated any data at all
on the CAN-Interior bus.</p>

<p>Some actions result in multiple messages being generated. In particular, the
lights appear to generate two message id’s when state is changed, one to two
with id <code class="language-plaintext highlighter-rouge">$208</code> and another with id <code class="language-plaintext highlighter-rouge">$2e1</code>. Here’s what I’ve found so far:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>208 00 22 6d 5a 1e 01 2c # Lights on w/ fogs
208 58 22 6d 51 1e 01 2c
2e1 1a

208 00 22 6d 5a 1e 01 2c # Lights off w/ fogs  
2e1 1b

2e1 1b # Fogs on  
2e1 0b # Fogs off  
2e1 0a # Lights on w/o fogs  
2e1 0b # Lights off w/o fogs

The Radio generates a lot of data, too:  

</code></pre></div></div>
<p>29e 00 03 97 20 02 ff ff ff # Change to FM 91.9`</p>

<p>291 09 01 05 30 f0 00 07 # Change to satellite, w/ no signal<br />
293 00 00 b8 20 02 ff ff ff</p>

<p>291 01 01 05 10 10 00 07 # Change to FM, 91.5<br />
291 00 03 93 20 02 ff ff ff</p>

<p>291 09 01 05 30 80 00 07 # Change satellite stations<br />
293 00 00 19 23 02 ff ff ff<br />
295 43 65 73 52 65 77 6e 64 # ClsRewnd</p>

<p>29e 00 00 0f 21 02 00 00 00 # Change CD tracks, byte 3</p>

<p>3d9 0a 0a 0a 0a 0a ff # Change volume, byte 0<br />
3d9 08 0a 0a 0a 0a ff # Change volume, byte 0
```</p>

<p>Message id <code class="language-plaintext highlighter-rouge">$295</code> is the most fun, as any message broadcast with that id will
appear on the vehicle’s EVIC message line, assuming you have disabled the ECO
option from being displayed.</p>

<p>Stay tuned for more information about the bus, how to setup both the Arduino
and Raspberry Pi to talk to a CAN bus, and details about upcoming projects.</p>

<h2 id="resources">Resources</h2>

<ul>
  <li>TE Connectivity makes the MULTILOCK connector’s used by Mopar for the Radio C2 wiring harness: <a href="http://www.te.com/catalog/pn/en/1438759-1?RQPN=1438759-1" title="TE MULTILOCK Connector 1438759-1">http://www.te.com/catalog/pn/en/1438759-1?RQPN=1438759-1</a></li>
  <li>SK Pang makes CAN interface boards for use with both the Raspberry Pi and Arduino platforms: <a href="http://skpang.co.uk/catalog/pican-canbus-board-for-raspberry-pi-p-1196.htm" title="Raspberry Pi CAN-Bus Interface Board">http://skpang.co.uk/catalog/pican-canbus-board-for-raspberry-pi-p-1196.htm</a>l and <a href="http://skpang.co.uk/catalog/arduino-canbus-shield-with-usd-card-holder-p-706.html" title="Arduino CAN-Bus Shield">http://skpang.co.uk/catalog/arduino-canbus-shield-with-usd-card-holder-p-706.html</a></li>
  <li>SparkFun is a Boulder-based company that also sells the CAN-Bus Shield for Arduino: <a href="https://www.sparkfun.com/products/10039" title="Arduino CAN-Bus Shield">https://www.sparkfun.com/products/10039</a></li>
  <li>Microchip makes the <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010406" title="MCP2515 CAN Controller with SPI">MCP2515</a> CAN controller IC, and the <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010405" title="MCP2551 CAN Transceiver">MCP2551</a> CAN transceiver IC, low-cost chips for interfacing with CAN busses.</li>
  <li><a href="http://arduino.cc/" title="Arduino">Arduino</a> makes low-cost embedded platforms using ATMEL micro-controllers, using open-source and open-hardware licenses.</li>
  <li><a href="http://www.raspberrypi.org" title="Raspberry Pi">Raspberry Pi</a>makes low-cost embedded platforms using ARM CPUs that run Linux, using open-source and open-hardware licenses.</li>
</ul>

<h2 id="videos">Videos</h2>

<h3 id="part-1---installing-the-custom-wiring-harness">Part 1 - Installing the custom wiring harness</h3>

<p><a href="https://youtu.be/JjYreU3H0hw" target="_blank">https://youtu.be/JjYreU3H0hw</a></p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/JjYreU3H0hw" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe>

<h3 id="part-2---routing-the-can-bus-extension">Part 2 - routing the CAN-Bus extension</h3>

<p><a href="https://youtu.be/fTPKRqLchs0" target="_blank">https://youtu.be/fTPKRqLchs0</a></p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/fTPKRqLchs0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe>

<h3 id="part-3---hooking-up-the-bus-to-the-raspberry-pi">Part 3 - Hooking up the bus to the Raspberry Pi</h3>

<p><a href="https://youtu.be/pboA7_q0f-E" target="_blank">https://youtu.be/pboA7_q0f-E</a></p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/pboA7_q0f-E" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe>

<h3 id="part-4---using-linux-to-analyze-can-bus-data">Part 4 - Using Linux to Analyze CAN-Bus Data</h3>

<p><a href="https://youtu.be/A9Sdc_j2i6I" target="_blank">https://youtu.be/A9Sdc_j2i6I</a></p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/A9Sdc_j2i6I" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe>

<h3 id="part-5---sending-custom-messages-to-the-evic">Part 5 - Sending Custom Messages to the EVIC</h3>

<p><a href="https://youtu.be/gHwQwhEFE34" target="_blank">https://youtu.be/gHwQwhEFE34</a></p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/gHwQwhEFE34" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe>

<h3 id="part-6---what-happens-if-you-corrupt-the-can-bus">Part 6 - What Happens if you Corrupt the CAN-Bus</h3>

<p><a href="https://youtu.be/FuIBvmrVpGA" target="_blank">https://youtu.be/FuIBvmrVpGA</a></p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/FuIBvmrVpGA" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe>]]></content><author><name>chadwick</name></author><category term="cars" /><category term="technology" /><category term="automobile" /><category term="can" /><category term="can-bus" /><category term="car" /><category term="electronics" /><category term="hacking" /><category term="jeep" /><category term="jk" /><category term="jku" /><summary type="html"><![CDATA[The Jeep’s Electronic Vehicle Information Center (EVIC) Displays a Custom Message]]></summary></entry><entry><title type="html">JavaScript Evaluation for Erlang Applications</title><link href="https://chadgibbons.com/2013/10/08/javascript-evaluation-for-erlang-applications/" rel="alternate" type="text/html" title="JavaScript Evaluation for Erlang Applications" /><published>2013-10-08T20:57:57+00:00</published><updated>2013-10-08T20:57:57+00:00</updated><id>https://chadgibbons.com/2013/10/08/javascript-evaluation-for-erlang-applications</id><content type="html" xml:base="https://chadgibbons.com/2013/10/08/javascript-evaluation-for-erlang-applications/"><![CDATA[<p>If you are an Erlang developer you are likely familiar with the
<a href="http://basho.com/riak/" title="Riak">Riak</a> storage engine, and how the MapReduce
feature can evaluate arbitrary JavaScript expressions. Can you use this same
code to do your own JavaScript evaluations for your Erlang projects? Yes, and
it turns out to be surprisingly easily.</p>

<p>Getting your development environment running <code class="language-plaintext highlighter-rouge">erlang_js</code> is the first order of
business. I’ve done all of my testing on a Mac OS X system, both Lion (10.7)
and Mavericks (10.9). I use Erlang <code class="language-plaintext highlighter-rouge">R14B04</code> for these tests, since that
version is what we primarily target at the office.</p>

<p>If you want to manage multiple versions of Erlang on your OS X system, I
highly recommend the <a href="https://github.com/mrallen1/erlbrew" title="elbrew">erlbrew</a>
utility as a quick and easy way to maintain multiple versions. We’ve recently
made it support R14 builds on OS X Mavericks, so there’s no excuse not to use
it!</p>

<p>Assuming you have a working Erlang and OS X command-line development tools
active, execute the following to checkout the <code class="language-plaintext highlighter-rouge">erlang_js</code> project and build it
locally:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone git://github.com/basho/erlang_js.git
cd erlang_js
make all test
</code></pre></div></div>

<p>One of the most compelling uses of a JavaScript engine from another language
like Erlang is the ability to pass arbitrarily deep objects as JSON so they
can be evaluated. This allows your application to use JavaScript as a
general-purpose expression language even if the objects are backed by an
Erlang term. This is effectively what you get with Riak when using the
MapReduce feature.</p>

<p>As an example, let’s imagine a deeply nested data structure that represents a
server configuration. We’d like to execute a JavaScript expression against
that data to find the first active network interface. Here’s an example of how
you’d do it using <code class="language-plaintext highlighter-rouge">erlang_js</code>:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>% Start the erlang_js application and driver. 
ok = application:start(erlang_js). 
{ok, JSDriver} = js_driver:new(). 

% Create a deeply-nested data structure to evaluate 
ServerObj = {struct, [{&lt;&lt;"id"&gt;&gt;,&lt;&lt;"foobar.example.org"&gt;&gt;}, {&lt;&lt;"type"&gt;&gt;,&lt;&lt;"linux"&gt;&gt;}, {&lt;&lt;"interfaces"&gt;&gt;, [ {struct, [ {&lt;&lt;"name"&gt;&gt;,&lt;&lt;"eth0"&gt;&gt;}, {&lt;&lt;"ipaddress"&gt;&gt;,&lt;&lt;"192.168.1.101"&gt;&gt;}, {&lt;&lt;"enabled"&gt;&gt;,true}]}, {struct, [{&lt;&lt;"name"&gt;&gt;,&lt;&lt;"eth1"&gt;&gt;}, {&lt;&lt;"ipaddress"&gt;&gt;,&lt;&lt;"192.168.1.102"&gt;&gt;}, {&lt;&lt;"enabled"&gt;&gt;,true}]}, {struct, [{&lt;&lt;"name"&gt;&gt;,&lt;&lt;"bridge0"&gt;&gt;}, {&lt;&lt;"enabled"&gt;&gt;,false}]} ]} ]}. 

% Evaluate our object with an arbitrary JavaScript expression 
JSFun = &lt;&lt;"function is_any_interface_enabled(Server) { for (var i = 0; i \&lt; Server.interfaces.length; i++) { if (Server.interfaces[i].enabled) return true; } return false; }"&gt;&gt;. 
js:call(JSDriver, JSFun, [ServerObj]).
</code></pre></div></div>

<p>The real trick is building your Erlang data structure properly so that the
custom version of <code class="language-plaintext highlighter-rouge">mochijson2</code> can encode the object as JSON. As you see from
the examples, use tuples with a <code class="language-plaintext highlighter-rouge">struct</code> atom as the first member to specify
an object. Arrays are just arrays.</p>

<p>I have noticed that it is very easy to confuse a single instance of the
<code class="language-plaintext highlighter-rouge">js_driver</code> object and it is hosed until a new one is created, so consider
that in how you structure your driver usage.</p>]]></content><author><name>chadwick</name></author><category term="software development" /><category term="technology" /><category term="erlang" /><category term="javascript" /><category term="json" /><summary type="html"><![CDATA[If you are an Erlang developer you are likely familiar with the Riak storage engine, and how the MapReduce feature can evaluate arbitrary JavaScript expressions. Can you use this same code to do your own JavaScript evaluations for your Erlang projects? Yes, and it turns out to be surprisingly easily.]]></summary></entry></feed>