{"id":199,"date":"2015-07-23T17:34:22","date_gmt":"2015-07-23T17:34:22","guid":{"rendered":"http:\/\/jb0.de\/?p=199"},"modified":"2016-10-28T08:37:55","modified_gmt":"2016-10-28T08:37:55","slug":"music-player-gets-can-bus","status":"publish","type":"post","link":"https:\/\/jb0.de\/?p=199","title":{"rendered":"Music-Player gets CAN-BUS!"},"content":{"rendered":"<h2>Lets&#8217;s get deeper in the car&#8217;s electronics<\/h2>\n<p>My XBMC-Mediacenter works pretty well. But the only way to skip a song is the I\/R remote placed in my armrest and to see what song is playing, I need to switch the whole display to mediacenter mode.<br \/>\nBecause I always wanted to take a closer look at the CAN-BUS in my <a href=\"https:\/\/en.wikipedia.org\/wiki\/Opel_Astra#Astra_H_.282004.E2.80.932009.29\">opel astra<\/a>, I decided to give the music player another update.<\/p>\n<p>So I ordered a\u00a0<a href=\"http:\/\/www.industrialberry.com\/canberry-v-1-1\/\">MCP2515\u00a0\/\u00a0MCP2551 CAN-BUS interface for a raspberry pi<\/a> and started to scan the bus.<\/p>\n<p>The opel astra h (2004-2010) has the following busses:<\/p>\n<ul>\n<li>SW-CAN (SingleWire)\u00a033.3 kbps also known as &#8220;GMLAN&#8221;<\/li>\n<li>MS-CAN (MidSpeed) 95.0 kbps<\/li>\n<li>HS-CAN (HighSpeed) 500 kbps<\/li>\n<\/ul>\n<h2>The\u00a0car body bus<\/h2>\n<p>The first was to capture some &#8220;base noise&#8221; with the bus awake and the ignition off. Then I performed some actions like pressing buttons, locking\/unlocking the car etc.<br \/>\nThat capture could be compared to the base noise to identify the messages only send in that capture. That gave me some results:<\/p>\n<p><a href=\"http:\/\/jb0.de\/wp-content\/uploads\/2015\/07\/CAN_Key_Commands.png\"><img loading=\"lazy\" decoding=\"async\" width=\"405\" height=\"189\" class=\"alignnone size-full wp-image-202\" src=\"http:\/\/jb0.de\/wp-content\/uploads\/2015\/07\/CAN_Key_Commands.png\" alt=\"CAN_Key_Commands\" srcset=\"https:\/\/jb0.de\/wp-content\/uploads\/2015\/07\/CAN_Key_Commands.png 405w, https:\/\/jb0.de\/wp-content\/uploads\/2015\/07\/CAN_Key_Commands-300x140.png 300w\" sizes=\"auto, (max-width: 405px) 100vw, 405px\" \/><\/a><\/p>\n<p>This means that when I send 160#0340C803, followd by 160#0300C803, the car locks!\u00a0This point was a huge milestone!<\/p>\n<div id=\"wpbgallery_container\"><ul id=\"wpbgallery\" class=\"clearfix\"><li><a href=\"https:\/\/jb0.de\/wp-content\/uploads\/2015\/07\/can_lock.jpg\" title=\"can_lock\" data-gallery=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jb0.de\/wp-content\/uploads\/2015\/07\/can_lock-150x150.jpg\" width=\"150\" height=\"150\" alt=\"can_lock\" \/><\/a><\/li><\/ul><\/div><div id=\"blueimp-gallery\" class=\"blueimp-gallery\" data-useBootstrapModal=\"1\" data-fullScreen=\"0\">\r\n            <div class=\"slides\"><\/div>\r\n            <h3 class=\"title\"><\/h3><a class=\"prev\">&#xffe9;<\/a>\r\n        <a class=\"next\">&#xffeb;<\/a>\r\n        <a class=\"close\">&#120;<\/a>\r\n        <a class=\"play-pause\"><\/a>\r\n        <ol class=\"indicator\"><\/ol>\r\n        <div class=\"modal fade\">\r\n            <div class=\"modal-dialog\">\r\n                <div class=\"modal-content\">\r\n                    <div class=\"modal-header\">\r\n                        <button type=\"button\" class=\"close\" aria-hidden=\"true\">&times;<\/button>\r\n                        <h4 class=\"modal-title\"><\/h4>\r\n                    <\/div>\r\n                    <div class=\"modal-body next\"><\/div>\r\n                    <div class=\"modal-footer\">\r\n                        <button type=\"button\" class=\"btn btn-default pull-left prev\">\r\n                            Previous\r\n                        <\/button>\r\n                        <button type=\"button\" class=\"btn btn-primary next\">\r\n                            Next\r\n                        <\/button>\r\n                    <\/div>\r\n                <\/div>\r\n            <\/div>\r\n        <\/div>\r\n    <\/div>\n<h2>The entertainment bus<\/h2>\n<p>What I really was interested on was the MS-CAN with the unusual 95 kbps!<br \/>\nSo I did the same as above and found what I wanted:<\/p>\n<pre><strong>206 # 01 91 00<\/strong> - Steering Remote UP\r\n<strong>206 # 01 92 00<\/strong> - Steering Remote Down<\/pre>\n<p>I also found the outdoor temperature:<\/p>\n<pre><strong>683 # 46 01 XX<\/strong> where the temp in celsius is XX\/2-40 so 0x00 is -20.0\u00b0C and 0x76 is 19.0\u00b0C.<\/pre>\n<p>But the really cool data goes to the display:<\/p>\n<pre><strong>6C1 # 10 2E C0 00 2B 03 01 01<\/strong>\r\n<strong>6C1 # 21 00 20 23 03 00 41 00<\/strong>\r\n<strong>6C1 # 22 75 00 78 10 0A 00 1B<\/strong>\r\n<strong>6C1 # 23 00 5B 00 66 00 53 00<\/strong>\r\n<strong>6C1 # 24 5F 00 67 00 6D 00 41<\/strong>\r\n<strong>6C1 # 25 00 75 00 78 11 01 00<\/strong>\r\n<strong>6C1 # 26 20 12 01 00 20 01 00<\/strong><\/pre>\n<p>The first byte of the packet identifies a multi-packet message. It starts with 0x10, than follows 0x2X where X increments from 1 to F. So after 0x2F comes 0x20, 0x21&#8230;<br \/>\nThe second Byte of the first packet is the number in Bytes. The last packet is always 8 Byte long but the rest is ignored (these are either filled with 0x00 or the same then the previous package).<br \/>\nThan are two byte of command or mode. This is 0x4000, 0xC000, 0x5000 or 0xA000. Don&#8217;t know what that means&#8230; Than comes the size and type of the following container. Type 0x03 seems to update the main screen.<br \/>\nNow follow some strings, starting with an ID (here 0x01,0x10,0x11 and 0x12), the number of\u00a0characters and the characters in UTF-16 (where only very vew unicode-chars are supported but that comes in the next post).<\/p>\n<p>That&#8217;s all&#8230;<\/p>\n<p>This is a schematic view of the above packet:<\/p>\n<div id=\"wpbgallery_container\"><ul id=\"wpbgallery\" class=\"clearfix\"><li><a href=\"https:\/\/jb0.de\/wp-content\/uploads\/2015\/07\/CAN_schematic.png\" title=\"CAN_schematic\" data-gallery=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jb0.de\/wp-content\/uploads\/2015\/07\/CAN_schematic-150x150.png\" width=\"150\" height=\"150\" alt=\"CAN_schematic\" \/><\/a><\/li><\/ul><\/div><div id=\"blueimp-gallery\" class=\"blueimp-gallery\" data-useBootstrapModal=\"1\" data-fullScreen=\"0\">\r\n            <div class=\"slides\"><\/div>\r\n            <h3 class=\"title\"><\/h3><a class=\"prev\">&#xffe9;<\/a>\r\n        <a class=\"next\">&#xffeb;<\/a>\r\n        <a class=\"close\">&#120;<\/a>\r\n        <a class=\"play-pause\"><\/a>\r\n        <ol class=\"indicator\"><\/ol>\r\n        <div class=\"modal fade\">\r\n            <div class=\"modal-dialog\">\r\n                <div class=\"modal-content\">\r\n                    <div class=\"modal-header\">\r\n                        <button type=\"button\" class=\"close\" aria-hidden=\"true\">&times;<\/button>\r\n                        <h4 class=\"modal-title\"><\/h4>\r\n                    <\/div>\r\n                    <div class=\"modal-body next\"><\/div>\r\n                    <div class=\"modal-footer\">\r\n                        <button type=\"button\" class=\"btn btn-default pull-left prev\">\r\n                            Previous\r\n                        <\/button>\r\n                        <button type=\"button\" class=\"btn btn-primary next\">\r\n                            Next\r\n                        <\/button>\r\n                    <\/div>\r\n                <\/div>\r\n            <\/div>\r\n        <\/div>\r\n    <\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>With that knowledge, I generated my own packet:<\/p>\n<pre><strong>6C1 # 10 54 C0 00 51 03 01 01<\/strong> - 84 Bytes, mode 0xC000, 81 Bytes payload, type 0x03, id 0x01, 1 char<strong>\r\n6C1 # 21 00 20 02 03 00 41 00<\/strong> - Whitespace, id 0x02, A<strong>\r\n6C1 # 22 75 00 78 10 07 00 48<\/strong> - u x, mode 0x10, 7 chars, H<strong>\r\n6C1 # 23 00 61 00 63 00 6B 00<\/strong> - a, c, k<strong>\r\n6C1 # 24 65 00 64 00 21 11 0C<\/strong> - e, d, !, id 0x11, 12 chars<strong>\r\n6C1 # 25 00 76 00 69 00 73 00<\/strong> - v, i, s<strong>\r\n6C1 # 26 69 00 74 00 20 00 6A<\/strong> - i, t, Whitespace, j<strong>\r\n6C1 # 27 00 62 00 30 00 2E 00<\/strong> - b, 0, .<strong>\r\n6C1 # 28 64 00 65 12 0C 00 68<\/strong> - d, e, id 0x12, 12 chars, h<strong>\r\n6C1 # 29 00 61 00 63 00 6B 00<\/strong> - a, c, k<strong>\r\n6C1 # 2A 61 00 64 00 61 00 79<\/strong> - a, d, a, y<strong>\r\n6C1 # 2B 00 2E 00 63 00 6F 00<\/strong> - ., c. o<strong>\r\n6C1 # 2C 6D 00 00 00 00 00 00<\/strong> - m<\/pre>\n<p>And what happened? This:<\/p>\n<div id=\"wpbgallery_container\"><ul id=\"wpbgallery\" class=\"clearfix\"><li><a href=\"https:\/\/jb0.de\/wp-content\/uploads\/2015\/07\/20150703_112814_HDR.jpg\" title=\"20150703_112814_HDR\" data-gallery=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jb0.de\/wp-content\/uploads\/2015\/07\/20150703_112814_HDR-150x150.jpg\" width=\"150\" height=\"150\" alt=\"20150703_112814_HDR\" \/><\/a><\/li><\/ul><\/div><div id=\"blueimp-gallery\" class=\"blueimp-gallery\" data-useBootstrapModal=\"1\" data-fullScreen=\"0\">\r\n            <div class=\"slides\"><\/div>\r\n            <h3 class=\"title\"><\/h3><a class=\"prev\">&#xffe9;<\/a>\r\n        <a class=\"next\">&#xffeb;<\/a>\r\n        <a class=\"close\">&#120;<\/a>\r\n        <a class=\"play-pause\"><\/a>\r\n        <ol class=\"indicator\"><\/ol>\r\n        <div class=\"modal fade\">\r\n            <div class=\"modal-dialog\">\r\n                <div class=\"modal-content\">\r\n                    <div class=\"modal-header\">\r\n                        <button type=\"button\" class=\"close\" aria-hidden=\"true\">&times;<\/button>\r\n                        <h4 class=\"modal-title\"><\/h4>\r\n                    <\/div>\r\n                    <div class=\"modal-body next\"><\/div>\r\n                    <div class=\"modal-footer\">\r\n                        <button type=\"button\" class=\"btn btn-default pull-left prev\">\r\n                            Previous\r\n                        <\/button>\r\n                        <button type=\"button\" class=\"btn btn-primary next\">\r\n                            Next\r\n                        <\/button>\r\n                    <\/div>\r\n                <\/div>\r\n            <\/div>\r\n        <\/div>\r\n    <\/div>\n<p>&nbsp;<\/p>\n<p>Next:\u00a0<a href=\"http:\/\/jb0.de\/?p=227\">Fully working prototype<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lets&#8217;s get deeper in the car&#8217;s electronics My XBMC-Mediacenter works pretty well. But the only way to skip a song is the I\/R remote placed in my armrest and to see what song is playing, I need to switch the whole display to mediacenter mode. Because I always wanted to take a closer look at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":204,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,3,22],"tags":[34,4,5],"class_list":["post-199","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-can-bus","category-car-mediacenter","category-electronic-upgrades","tag-can-bus","tag-car","tag-raspberry"],"_links":{"self":[{"href":"https:\/\/jb0.de\/index.php?rest_route=\/wp\/v2\/posts\/199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jb0.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jb0.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jb0.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jb0.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=199"}],"version-history":[{"count":17,"href":"https:\/\/jb0.de\/index.php?rest_route=\/wp\/v2\/posts\/199\/revisions"}],"predecessor-version":[{"id":288,"href":"https:\/\/jb0.de\/index.php?rest_route=\/wp\/v2\/posts\/199\/revisions\/288"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jb0.de\/index.php?rest_route=\/wp\/v2\/media\/204"}],"wp:attachment":[{"href":"https:\/\/jb0.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jb0.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jb0.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}