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
- Committer:
- foxdie
- Date:
- 2013-02-19
- Revision:
- 1:9dfa8ee351a3
- Parent:
- 0:9266fbfbef88
- Child:
- 2:1a2cb289f24d
File content as of revision 1:9dfa8ee351a3:
/* GMLAN.h - Header file for GMLAN Library GMLAN is a Controller Area Network Bus used in General Motors vehicles from roughly 2007-onwards. Its purpose is to allow various Electronic Control Units (aka ECUs) within a modern vehicle to share information and enact procedures. An example of this would be communication between the HU (Head unit) and the DIC (Dashboard Information Cluster), when you adjust the volume up / down, this is reported to the cluster to be displayed. It is the function of this library to "crack open" this world to allow anyone with only as little as a few hours of C++ programming under their belt to get started in what can sometimes seem a daunting world. Jason Gaunt, 18th Feb 2013 */ #ifndef GMLAN_H #define GMLAN_H /* Baud rates of various services */ #define GMLAN_BAUD_LS_NORMAL 33333 #define GMLAN_BAUD_LS_FAST 83333 #define GMLAN_BAUD_MS 95200 #define GMLAN_BAUD_HS 500000 class CANHeader { // Example header packet for Steering Wheel Switches: // Hexadecimal: 0x10 0x0D 0x00 0x60 // Binary: 00010000 00001101 00000000 01100000 // Priority: --- // Arbitration: -- -------- --- // Sending ECU: ----- -------- private: int priorityID, arbitrationID, senderID; public: // Main function CANHeader() { } //// 29-bit frames // Methods for getting / setting priority, both integers int priority(void) { return priorityID; } void priority(int _priority) { priorityID = _priority; } // Method for getting / setting arbitration id aka arbid, both integers int arbitration(void) { return arbitrationID; } void arbitration(int _arbitration) { arbitrationID = _arbitration; } // Method for getting / setting sender id, both integers int sender(void) { return senderID; } void sender(int _sender) { senderID = _sender; } // Function to decode a header packet and store values in respective variables void decode(int _header); // Function to encode stored values and return header packet as int int encode(void); }; #endif