Libraries to support working with GMLAN - General Motors CAN BUS network in most of their vehicles between 2007-present day. Please note this is a work in progress and not guaranteed to be correct, use at your own risk! Read commit logs / subscribe to see what has been added, it's a work in progress after all ;)
GMLAN.cpp@2:1a2cb289f24d, 2013-02-19 (annotated)
- Committer:
- foxdie
- Date:
- Tue Feb 19 22:28:25 2013 +0000
- Revision:
- 2:1a2cb289f24d
- Parent:
- 0:9266fbfbef88
- Child:
- 3:09fdfec053cd
Added initial list of known Arbitration IDs from the GMLAN Bible located at http://is.gd/gmlanbible - a project I am a curator of. Credit also due to TMK for his hard work too and the other developers who work tirelessly.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
foxdie | 0:9266fbfbef88 | 1 | /* |
foxdie | 0:9266fbfbef88 | 2 | GMLAN.cpp - Source file for GMLAN Library |
foxdie | 0:9266fbfbef88 | 3 | |
foxdie | 0:9266fbfbef88 | 4 | GMLAN is a Controller Area Network Bus used in General Motors vehicles from |
foxdie | 0:9266fbfbef88 | 5 | roughly 2007-onwards. Its purpose is to allow various Electronic Control Units |
foxdie | 0:9266fbfbef88 | 6 | (aka ECUs) within a modern vehicle to share information and enact procedures. |
foxdie | 0:9266fbfbef88 | 7 | |
foxdie | 0:9266fbfbef88 | 8 | An example of this would be communication between the HU (Head unit) and the |
foxdie | 0:9266fbfbef88 | 9 | DIC (Dashboard Information Cluster), when you adjust the volume up / down, this |
foxdie | 0:9266fbfbef88 | 10 | is reported to the cluster to be displayed. |
foxdie | 0:9266fbfbef88 | 11 | |
foxdie | 0:9266fbfbef88 | 12 | It is the function of this library to "crack open" this world to allow anyone |
foxdie | 0:9266fbfbef88 | 13 | with only as little as a few hours of C++ programming under their belt to get |
foxdie | 0:9266fbfbef88 | 14 | started in what can sometimes seem a daunting world. |
foxdie | 0:9266fbfbef88 | 15 | |
foxdie | 0:9266fbfbef88 | 16 | Jason Gaunt, 18th Feb 2013 |
foxdie | 0:9266fbfbef88 | 17 | */ |
foxdie | 0:9266fbfbef88 | 18 | |
foxdie | 0:9266fbfbef88 | 19 | #include "GMLAN.h" |
foxdie | 0:9266fbfbef88 | 20 | |
foxdie | 0:9266fbfbef88 | 21 | void CANHeader::decode(int _header) { |
foxdie | 0:9266fbfbef88 | 22 | priorityID = (_header >> 26) & 0x7; |
foxdie | 0:9266fbfbef88 | 23 | arbitrationID = (_header >> 13) & 0x1FFF; |
foxdie | 0:9266fbfbef88 | 24 | senderID = (_header >> 0) & 0x1FFF; |
foxdie | 0:9266fbfbef88 | 25 | } |
foxdie | 0:9266fbfbef88 | 26 | int CANHeader::encode(void) { |
foxdie | 0:9266fbfbef88 | 27 | long int buffer = 0; |
foxdie | 0:9266fbfbef88 | 28 | buffer = (buffer << 3) | 0x0; // 3 bit padding |
foxdie | 0:9266fbfbef88 | 29 | buffer = (buffer << 3) | priorityID; |
foxdie | 0:9266fbfbef88 | 30 | buffer = (buffer << 13) | arbitrationID; |
foxdie | 0:9266fbfbef88 | 31 | buffer = (buffer << 13) | senderID; |
foxdie | 0:9266fbfbef88 | 32 | return buffer; |
foxdie | 0:9266fbfbef88 | 33 | } |