Just4Trionic - CAN and BDM FLASH programmer for Saab cars
Fork of Just4Trionic by
Diff: gmlan.h
- Revision:
- 5:1775b4b13232
- Parent:
- 4:682d96ff6d79
diff -r 682d96ff6d79 -r 1775b4b13232 gmlan.h --- a/gmlan.h Wed Sep 11 11:55:51 2013 +0000 +++ b/gmlan.h Sat Apr 25 17:07:08 2015 +0000 @@ -11,8 +11,13 @@ #include "common.h" #include "canutils.h" -#define T8RequestId 0x7E0 -#define T8ResponseId 0x7E8 +#define T8REQID 0x7E0 +#define T8RESPID 0x7E8 + +#define T8USDTREQID 0x011 +#define T8UUDTRESPID 0x311 +#define T8USDTRESPID 0x411 + #define GMLANALLNODES 0x101 #define GMLANMESSAGETIMEOUT 50 // 50 milliseconds (0.05 of a second) - Seems to be plenty of time to wait for messages on the CAN bus @@ -24,42 +29,42 @@ #define GMLANTesterPresentPhysical {0x01,0x3E,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa} #define GMLANTesterPresentFunctional {0xFE,0x01,0x3E,0xaa,0xaa,0xaa,0xaa,0xaa} extern void GMLANTesterPresentAll(); -extern void GMLANTesterPresentT8(); +extern void GMLANTesterPresent(uint32_t ReqID, uint32_t RespID); // All steps needed in preparation for using a bootloader ('Utility File' in GMLAN parlance) -bool GMLANprogrammingSetupProcess(); +bool GMLANprogrammingSetupProcess(uint32_t ReqID, uint32_t RespID); // All steps needed to transfer and start a bootloader ('Utility File' in GMLAN parlance) -bool GMLANprogrammingUtilityFileProcess(char UtilityFile[]); +bool GMLANprogrammingUtilityFileProcess(uint32_t ReqID, uint32_t RespID, const uint8_t UtilityFile[]); // Start a Diagnostic Session #define GMLANinitiateDiagnosticOperation {0x02,0x10,0x02,0xaa,0xaa,0xaa,0xaa,0xaa} #define GMLANdisableAllDTCs 0x02 -bool GMLANinitiateDiagnostic(char level); +bool GMLANinitiateDiagnostic(uint32_t ReqID, uint32_t RespID, char level); // Tell T8 To disable normal communication messages #define GMLANdisableCommunication {0x01,0x28,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa} -bool GMLANdisableNormalCommunication(); +bool GMLANdisableNormalCommunication(uint32_t ReqID, uint32_t RespID); // Tell T8 To report programmed state #define GMLANReportProgrammed {0x01,0xA2,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa} -bool GMLANReportProgrammedState(); +bool GMLANReportProgrammedState(uint32_t ReqID, uint32_t RespID); // Tell T8 To request or initiate programming #define GMLANProgramming {0x02,0xA5,0x00,0xaa,0xaa,0xaa,0xaa,0xaa} #define GMLANRequestProgrammingNormal 0x01 // I or P-Bus speed #define GMLANRequestProgrammingFast 0x02 // 83.333 kbps for single-wire CAN #define GMLANEnableProgrammingMode 0x03 // Tell T8 To initiate programming -bool GMLANProgrammingMode(char mode); +bool GMLANProgrammingMode(uint32_t ReqID, uint32_t RespID, char mode); // authenticate with T8 #define GMLANSecurityAccessSeed {0x02,0x27,0x01,0xaa,0xaa,0xaa,0xaa,0xaa} -bool GMLANSecurityAccessRequest(char level, uint16_t& seed); +bool GMLANSecurityAccessRequest(uint32_t ReqID, uint32_t RespID, char level, uint16_t& seed); #define GMLANSecurityAccessKey {0x04,0x27,0x02,0xCA,0xFE,0xaa,0xaa,0xaa} -bool GMLANSecurityAccessSendKey(char level, uint16_t key); +bool GMLANSecurityAccessSendKey(uint32_t ReqID, uint32_t RespID, char level, uint16_t key); // Tell T8 We are Requesting a download session #define GMLANRequestDownloadMessage {0x06,0x34,0x00,0x00,0x00,0x00,0x00,0xaa} @@ -67,19 +72,20 @@ #define GMLANRequestDownloadModeEncrypted 0x01 #define GMLANRequestDownloadModeCompressed 0x10 #define GMLANRequestDownloadModeCompressedEncrypted 0x11 -bool GMLANRequestDownload(char dataFormatIdentifier); +bool GMLANRequestDownload(uint32_t ReqID, uint32_t RespID, char dataFormatIdentifier); // Data blocks are sent using this message type #define GMLANDataTransferMessage {0x10,0xF0,0x36,0x00,0xCA,0xFE,0xBA,0xBE} #define GMLANDOWNLOAD 0x00 #define GMLANEXECUTE 0x80 -bool GMLANDataTransfer(char length, char function, uint32_t address); -bool GMLANDataTransferFirstFrame(char length, char function, uint32_t address); -bool GMLANDataTransferConsecutiveFrame(char framenumber, char data[7]); +bool GMLANDataTransfer(uint32_t ReqID, uint32_t RespID, char length, char function, uint32_t address); +bool GMLANDataTransferFirstFrame(uint32_t ReqID, uint32_t RespID, char length, char function, uint32_t address); +bool GMLANDataTransferConsecutiveFrame(uint32_t ReqID, char framenumber, char data[7]); +bool GMLANDataTransferBlockAcknowledge(uint32_t RespID); // Tell T8 ECU to return to normal mode after FLASHing -#define GMLANRetrunToNormalModeMessage {0x01,0x20,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa} -bool GMLANReturnToNormalMode(); +#define GMLANReturnToNormalModeMessage {0x01,0x20,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa} +bool GMLANReturnToNormalMode(uint32_t ReqID, uint32_t RespID); // Show a description of GMLAN Return Codes when an error occurs