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.h@2:1a2cb289f24d, 2013-02-19 (annotated)
- Committer:
- foxdie
- Date:
- Tue Feb 19 22:28:25 2013 +0000
- Revision:
- 2:1a2cb289f24d
- Parent:
- 1:9dfa8ee351a3
- 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.h - Header 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 | 2:1a2cb289f24d | 19 | #include "GMLAN_29bit.h" |
foxdie | 2:1a2cb289f24d | 20 | // #include "GMLAN_11bit.h" |
foxdie | 2:1a2cb289f24d | 21 | |
foxdie | 0:9266fbfbef88 | 22 | #ifndef GMLAN_H |
foxdie | 0:9266fbfbef88 | 23 | #define GMLAN_H |
foxdie | 0:9266fbfbef88 | 24 | |
foxdie | 0:9266fbfbef88 | 25 | /* Baud rates of various services */ |
foxdie | 0:9266fbfbef88 | 26 | #define GMLAN_BAUD_LS_NORMAL 33333 |
foxdie | 0:9266fbfbef88 | 27 | #define GMLAN_BAUD_LS_FAST 83333 |
foxdie | 0:9266fbfbef88 | 28 | #define GMLAN_BAUD_MS 95200 |
foxdie | 0:9266fbfbef88 | 29 | #define GMLAN_BAUD_HS 500000 |
foxdie | 0:9266fbfbef88 | 30 | |
foxdie | 0:9266fbfbef88 | 31 | class CANHeader { |
foxdie | 0:9266fbfbef88 | 32 | // Example header packet for Steering Wheel Switches: |
foxdie | 0:9266fbfbef88 | 33 | // Hexadecimal: 0x10 0x0D 0x00 0x60 |
foxdie | 0:9266fbfbef88 | 34 | // Binary: 00010000 00001101 00000000 01100000 |
foxdie | 0:9266fbfbef88 | 35 | // Priority: --- |
foxdie | 0:9266fbfbef88 | 36 | // Arbitration: -- -------- --- |
foxdie | 0:9266fbfbef88 | 37 | // Sending ECU: ----- -------- |
foxdie | 0:9266fbfbef88 | 38 | |
foxdie | 0:9266fbfbef88 | 39 | private: |
foxdie | 0:9266fbfbef88 | 40 | int priorityID, arbitrationID, senderID; |
foxdie | 0:9266fbfbef88 | 41 | |
foxdie | 0:9266fbfbef88 | 42 | public: |
foxdie | 1:9dfa8ee351a3 | 43 | // Main function |
foxdie | 1:9dfa8ee351a3 | 44 | CANHeader() { } |
foxdie | 1:9dfa8ee351a3 | 45 | |
foxdie | 0:9266fbfbef88 | 46 | //// 29-bit frames |
foxdie | 0:9266fbfbef88 | 47 | // Methods for getting / setting priority, both integers |
foxdie | 0:9266fbfbef88 | 48 | int priority(void) { return priorityID; } |
foxdie | 0:9266fbfbef88 | 49 | void priority(int _priority) { priorityID = _priority; } |
foxdie | 0:9266fbfbef88 | 50 | // Method for getting / setting arbitration id aka arbid, both integers |
foxdie | 0:9266fbfbef88 | 51 | int arbitration(void) { return arbitrationID; } |
foxdie | 0:9266fbfbef88 | 52 | void arbitration(int _arbitration) { arbitrationID = _arbitration; } |
foxdie | 0:9266fbfbef88 | 53 | // Method for getting / setting sender id, both integers |
foxdie | 0:9266fbfbef88 | 54 | int sender(void) { return senderID; } |
foxdie | 0:9266fbfbef88 | 55 | void sender(int _sender) { senderID = _sender; } |
foxdie | 0:9266fbfbef88 | 56 | |
foxdie | 0:9266fbfbef88 | 57 | // Function to decode a header packet and store values in respective variables |
foxdie | 0:9266fbfbef88 | 58 | void decode(int _header); |
foxdie | 0:9266fbfbef88 | 59 | // Function to encode stored values and return header packet as int |
foxdie | 0:9266fbfbef88 | 60 | int encode(void); |
foxdie | 0:9266fbfbef88 | 61 | }; |
foxdie | 0:9266fbfbef88 | 62 | |
foxdie | 0:9266fbfbef88 | 63 | #endif |