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