Sophie Dexter
/
Just4Trionic
Just4Trionic - CAN and BDM FLASH programmer for Saab cars
t7can.cpp@5:1775b4b13232, 2015-04-25 (annotated)
- Committer:
- Just4pLeisure
- Date:
- Sat Apr 25 17:07:08 2015 +0000
- Revision:
- 5:1775b4b13232
- Parent:
- 4:682d96ff6d79
- Child:
- 6:2fbcbebed28c
Version 1.5 Is a significant milestone.; ; Supports BDM and CAN read and write of T5.x, T7 and T8 ECU's plus T8 recovery.; A Target Resident Driver for BDM gives a big speed boost.; Supports many alternative replacement FLASH chips for T5.x ECU's;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Just4pLeisure | 3:92dae9083c83 | 1 | /******************************************************************************* |
Just4pLeisure | 3:92dae9083c83 | 2 | |
Just4pLeisure | 3:92dae9083c83 | 3 | trionic7.cpp - CAN Bus functions for Just4Trionic by Just4pLeisure |
Just4pLeisure | 4:682d96ff6d79 | 4 | (c) 2011, 2012 by Sophie Dexter |
Just4pLeisure | 3:92dae9083c83 | 5 | |
Just4pLeisure | 3:92dae9083c83 | 6 | This C++ module provides functions for reading and writing the FLASH chips and |
Just4pLeisure | 3:92dae9083c83 | 7 | SRAM in Trionic7 ECUs. (Writing the adaption data back to SRAM not done yet). |
Just4pLeisure | 3:92dae9083c83 | 8 | |
Just4pLeisure | 3:92dae9083c83 | 9 | Some functions need an additional 'bootloader' program to be sent to the T5 ECU |
Just4pLeisure | 3:92dae9083c83 | 10 | before they can be used. These functions are: Identifying the T5 ECU type and |
Just4pLeisure | 3:92dae9083c83 | 11 | FLASH chips, dumping the FLASH chips, erasing the FLASH chips, writing to the |
Just4pLeisure | 3:92dae9083c83 | 12 | FLASH chips and calculating the FLASH chips' checksum. |
Just4pLeisure | 3:92dae9083c83 | 13 | |
Just4pLeisure | 3:92dae9083c83 | 14 | My version of the bootloader, BOOTY.S19, includes some features not in other |
Just4pLeisure | 3:92dae9083c83 | 15 | bootloaders; identifying the ECU and FLASH chip types, a 'safer' way of dumping |
Just4pLeisure | 3:92dae9083c83 | 16 | the FLASH chips and the ability to program AMD 29F010 type FLASH chips |
Just4pLeisure | 3:92dae9083c83 | 17 | |
Just4pLeisure | 3:92dae9083c83 | 18 | ******************************************************************************** |
Just4pLeisure | 3:92dae9083c83 | 19 | |
Just4pLeisure | 3:92dae9083c83 | 20 | WARNING: Use at your own risk, sadly this software comes with no guarantees. |
Just4pLeisure | 3:92dae9083c83 | 21 | This software is provided 'free' and in good faith, but the author does not |
Just4pLeisure | 3:92dae9083c83 | 22 | accept liability for any damage arising from its use. |
Just4pLeisure | 3:92dae9083c83 | 23 | |
Just4pLeisure | 3:92dae9083c83 | 24 | *******************************************************************************/ |
Just4pLeisure | 3:92dae9083c83 | 25 | |
Just4pLeisure | 3:92dae9083c83 | 26 | #include "t7can.h" |
Just4pLeisure | 3:92dae9083c83 | 27 | |
Just4pLeisure | 3:92dae9083c83 | 28 | // constants |
Just4pLeisure | 3:92dae9083c83 | 29 | #define CMD_BUF_LENGTH 32 ///< command buffer size |
Just4pLeisure | 3:92dae9083c83 | 30 | |
Just4pLeisure | 3:92dae9083c83 | 31 | // static variables |
Just4pLeisure | 3:92dae9083c83 | 32 | static char cmd_buffer[CMD_BUF_LENGTH]; ///< command string buffer |
Just4pLeisure | 3:92dae9083c83 | 33 | |
Just4pLeisure | 3:92dae9083c83 | 34 | //static uint32_t cmd_addr; ///< address (optional) |
Just4pLeisure | 3:92dae9083c83 | 35 | //static uint32_t cmd_value; ///< value (optional) |
Just4pLeisure | 3:92dae9083c83 | 36 | //static uint32_t cmd_result; ///< result |
Just4pLeisure | 3:92dae9083c83 | 37 | |
Just4pLeisure | 3:92dae9083c83 | 38 | //static uint32_t flash_start = 0; |
Just4pLeisure | 3:92dae9083c83 | 39 | |
Just4pLeisure | 3:92dae9083c83 | 40 | // private functions |
Just4pLeisure | 3:92dae9083c83 | 41 | uint8_t execute_t7_cmd(); |
Just4pLeisure | 3:92dae9083c83 | 42 | void t7_can_show_help(); |
Just4pLeisure | 3:92dae9083c83 | 43 | void t7_can_show_full_help(); |
Just4pLeisure | 3:92dae9083c83 | 44 | |
Just4pLeisure | 3:92dae9083c83 | 45 | void t7_can() { |
Just4pLeisure | 3:92dae9083c83 | 46 | // Start the CAN bus system |
Just4pLeisure | 4:682d96ff6d79 | 47 | // Note that at the moment this is only for T7 ECUs at 500 kbits |
Just4pLeisure | 3:92dae9083c83 | 48 | t7_can_show_help(); |
Just4pLeisure | 3:92dae9083c83 | 49 | |
Just4pLeisure | 4:682d96ff6d79 | 50 | char data[8]; |
Just4pLeisure | 4:682d96ff6d79 | 51 | printf("Trying to listen to CAN I-Bus (47619 Bit/s)...\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 52 | can_configure(2, 47619, 1); |
Just4pLeisure | 4:682d96ff6d79 | 53 | if (can_wait_timeout(T7ANYMSG, data, 8, T7MESSAGETIMEOUT)) { |
Just4pLeisure | 4:682d96ff6d79 | 54 | printf("Connected to Saab I-Bus\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 55 | printf("Switching to I-Bus active mode\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 56 | can_configure(2, 47619, 0); |
Just4pLeisure | 4:682d96ff6d79 | 57 | } else { |
Just4pLeisure | 4:682d96ff6d79 | 58 | printf("I did not receive any I-Bus messages\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 59 | printf("Trying to listen to CAN P-Bus (500 kBit/s)...\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 60 | can_configure(2, 500000, 1); |
Just4pLeisure | 4:682d96ff6d79 | 61 | if (can_wait_timeout(T7ANYMSG, data, 8, T7MESSAGETIMEOUT)) { |
Just4pLeisure | 4:682d96ff6d79 | 62 | printf("Connected to Saab P-Bus\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 63 | printf("Switching to P-Bus active mode\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 64 | can_configure(2, 500000, 0); |
Just4pLeisure | 4:682d96ff6d79 | 65 | } else { |
Just4pLeisure | 4:682d96ff6d79 | 66 | printf("I did not receive any P-Bus messages\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 67 | printf("Switching to P-Bus active mode\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 68 | can_configure(2, 500000, 0); |
Just4pLeisure | 4:682d96ff6d79 | 69 | if (can_wait_timeout(T7ANYMSG, data, 8, T7CONNECTTIMEOUT)) { |
Just4pLeisure | 4:682d96ff6d79 | 70 | printf("Connected to Saab P-Bus\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 71 | //can_active(); |
Just4pLeisure | 4:682d96ff6d79 | 72 | } else { |
Just4pLeisure | 4:682d96ff6d79 | 73 | printf("FAILED to connect!\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 74 | led4 = 1; |
Just4pLeisure | 4:682d96ff6d79 | 75 | } |
Just4pLeisure | 4:682d96ff6d79 | 76 | } |
Just4pLeisure | 4:682d96ff6d79 | 77 | } |
Just4pLeisure | 4:682d96ff6d79 | 78 | |
Just4pLeisure | 4:682d96ff6d79 | 79 | // if (t7_initialise()) |
Just4pLeisure | 4:682d96ff6d79 | 80 | // printf("Connected to Saab I-Bus\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 81 | // else { |
Just4pLeisure | 4:682d96ff6d79 | 82 | // printf("Opening CAN channel to Saab P-Bus (500 kBit/s)...\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 83 | // can_set_speed(500000); |
Just4pLeisure | 4:682d96ff6d79 | 84 | // if (t7_initialise()) |
Just4pLeisure | 4:682d96ff6d79 | 85 | // printf("Connected to Saab P-Bus\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 86 | // else { |
Just4pLeisure | 4:682d96ff6d79 | 87 | // printf("FAILED to connect!\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 88 | // led4 = 1; |
Just4pLeisure | 4:682d96ff6d79 | 89 | // } |
Just4pLeisure | 4:682d96ff6d79 | 90 | // } |
Just4pLeisure | 4:682d96ff6d79 | 91 | |
Just4pLeisure | 4:682d96ff6d79 | 92 | // if (t7_initialise()) |
Just4pLeisure | 4:682d96ff6d79 | 93 | // printf("Trionic 7 Connection OK\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 94 | // else |
Just4pLeisure | 4:682d96ff6d79 | 95 | // printf("Trionic 7 Connection Failed\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 96 | // t7_authenticate(); |
Just4pLeisure | 4:682d96ff6d79 | 97 | // if (t7_authenticate()) |
Just4pLeisure | 4:682d96ff6d79 | 98 | // printf("Security Key Accepted\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 99 | // else |
Just4pLeisure | 4:682d96ff6d79 | 100 | // printf("Security Key Failed\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 101 | |
Just4pLeisure | 4:682d96ff6d79 | 102 | // main loop |
Just4pLeisure | 3:92dae9083c83 | 103 | *cmd_buffer = '\0'; |
Just4pLeisure | 3:92dae9083c83 | 104 | char ret; |
Just4pLeisure | 3:92dae9083c83 | 105 | char rx_char; |
Just4pLeisure | 3:92dae9083c83 | 106 | while (true) { |
Just4pLeisure | 3:92dae9083c83 | 107 | // read chars from USB |
Just4pLeisure | 3:92dae9083c83 | 108 | // send received messages to the pc over USB connection |
Just4pLeisure | 3:92dae9083c83 | 109 | // This function displays any CAN messages that are 'missed' by the other functions |
Just4pLeisure | 3:92dae9083c83 | 110 | // Can messages might be 'missed' because they are received after a 'timeout' period |
Just4pLeisure | 3:92dae9083c83 | 111 | // or because they weren't expected, e.g. if the T5 ECU resets for some reason |
Just4pLeisure | 3:92dae9083c83 | 112 | // t7_show_can_message(); |
Just4pLeisure | 3:92dae9083c83 | 113 | silent_can_message(); |
Just4pLeisure | 3:92dae9083c83 | 114 | if (pc.readable()) { |
Just4pLeisure | 3:92dae9083c83 | 115 | // turn Error LED off for next command |
Just4pLeisure | 3:92dae9083c83 | 116 | led4 = 0; |
Just4pLeisure | 3:92dae9083c83 | 117 | rx_char = pc.getc(); |
Just4pLeisure | 3:92dae9083c83 | 118 | switch (rx_char) { |
Just4pLeisure | 3:92dae9083c83 | 119 | // 'ESC' key to go back to mbed Just4Trionic 'home' menu |
Just4pLeisure | 3:92dae9083c83 | 120 | case '\e': |
Just4pLeisure | 3:92dae9083c83 | 121 | can_close(); |
Just4pLeisure | 3:92dae9083c83 | 122 | return; |
Just4pLeisure | 3:92dae9083c83 | 123 | // end-of-command reached |
Just4pLeisure | 3:92dae9083c83 | 124 | case TERM_OK : |
Just4pLeisure | 3:92dae9083c83 | 125 | // execute command and return flag via USB |
Just4pLeisure | 3:92dae9083c83 | 126 | timer.reset(); |
Just4pLeisure | 3:92dae9083c83 | 127 | timer.start(); |
Just4pLeisure | 3:92dae9083c83 | 128 | ret = execute_t7_cmd(); |
Just4pLeisure | 3:92dae9083c83 | 129 | pc.putc(ret); |
Just4pLeisure | 3:92dae9083c83 | 130 | printf("Completed in %.3f seconds.\r\n", timer.read()); |
Just4pLeisure | 3:92dae9083c83 | 131 | // reset command buffer |
Just4pLeisure | 3:92dae9083c83 | 132 | *cmd_buffer = '\0'; |
Just4pLeisure | 3:92dae9083c83 | 133 | // light up LED |
Just4pLeisure | 3:92dae9083c83 | 134 | // ret == TERM_OK ? led_on(LED_ACT) : led_on(LED_ERR); |
Just4pLeisure | 3:92dae9083c83 | 135 | ret == TERM_OK ? led3 = 1 : led4 = 1; |
Just4pLeisure | 3:92dae9083c83 | 136 | break; |
Just4pLeisure | 3:92dae9083c83 | 137 | // another command char |
Just4pLeisure | 3:92dae9083c83 | 138 | default: |
Just4pLeisure | 3:92dae9083c83 | 139 | // store in buffer if space permits |
Just4pLeisure | 3:92dae9083c83 | 140 | if (StrLen(cmd_buffer) < CMD_BUF_LENGTH - 1) { |
Just4pLeisure | 3:92dae9083c83 | 141 | StrAddc(cmd_buffer, rx_char); |
Just4pLeisure | 3:92dae9083c83 | 142 | } |
Just4pLeisure | 3:92dae9083c83 | 143 | break; |
Just4pLeisure | 3:92dae9083c83 | 144 | } |
Just4pLeisure | 3:92dae9083c83 | 145 | } |
Just4pLeisure | 3:92dae9083c83 | 146 | } |
Just4pLeisure | 3:92dae9083c83 | 147 | } |
Just4pLeisure | 3:92dae9083c83 | 148 | |
Just4pLeisure | 3:92dae9083c83 | 149 | //----------------------------------------------------------------------------- |
Just4pLeisure | 3:92dae9083c83 | 150 | /** |
Just4pLeisure | 3:92dae9083c83 | 151 | Executes a command and returns result flag (does not transmit the flag |
Just4pLeisure | 3:92dae9083c83 | 152 | itself). |
Just4pLeisure | 3:92dae9083c83 | 153 | |
Just4pLeisure | 3:92dae9083c83 | 154 | @return command flag (success / failure) |
Just4pLeisure | 3:92dae9083c83 | 155 | */ |
Just4pLeisure | 3:92dae9083c83 | 156 | uint8_t execute_t7_cmd() { |
Just4pLeisure | 3:92dae9083c83 | 157 | |
Just4pLeisure | 4:682d96ff6d79 | 158 | char data[8]; |
Just4pLeisure | 3:92dae9083c83 | 159 | // uint8_t cmd_length = strlen(cmd_buffer); |
Just4pLeisure | 3:92dae9083c83 | 160 | // command groups |
Just4pLeisure | 3:92dae9083c83 | 161 | switch (*cmd_buffer) { |
Just4pLeisure | 3:92dae9083c83 | 162 | // CHECK_ARGLENGTH(0); |
Just4pLeisure | 3:92dae9083c83 | 163 | // Get the Symbol Table |
Just4pLeisure | 3:92dae9083c83 | 164 | case 'i' : |
Just4pLeisure | 4:682d96ff6d79 | 165 | if (t7_initialise()) { |
Just4pLeisure | 4:682d96ff6d79 | 166 | printf("Trionic 7 Connection OK\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 167 | return TERM_OK; |
Just4pLeisure | 4:682d96ff6d79 | 168 | } else { |
Just4pLeisure | 4:682d96ff6d79 | 169 | printf("Trionic 7 Connection Failed\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 170 | return TERM_ERR; |
Just4pLeisure | 4:682d96ff6d79 | 171 | } |
Just4pLeisure | 4:682d96ff6d79 | 172 | // return t7_initialise() |
Just4pLeisure | 4:682d96ff6d79 | 173 | // ? TERM_OK : TERM_ERR; |
Just4pLeisure | 3:92dae9083c83 | 174 | case 'a' : |
Just4pLeisure | 3:92dae9083c83 | 175 | case 'A' : |
Just4pLeisure | 4:682d96ff6d79 | 176 | if (t7_authenticate()) { |
Just4pLeisure | 4:682d96ff6d79 | 177 | printf("Security Key Accepted\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 178 | return TERM_OK; |
Just4pLeisure | 4:682d96ff6d79 | 179 | } else { |
Just4pLeisure | 4:682d96ff6d79 | 180 | printf("Security Key Failed\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 181 | return TERM_ERR; |
Just4pLeisure | 4:682d96ff6d79 | 182 | } |
Just4pLeisure | 4:682d96ff6d79 | 183 | // return t7_authenticate() |
Just4pLeisure | 4:682d96ff6d79 | 184 | // ? TERM_OK : TERM_ERR; |
Just4pLeisure | 3:92dae9083c83 | 185 | |
Just4pLeisure | 4:682d96ff6d79 | 186 | // Erase the FLASH chips |
Just4pLeisure | 3:92dae9083c83 | 187 | case 'e': |
Just4pLeisure | 3:92dae9083c83 | 188 | case 'E': |
Just4pLeisure | 3:92dae9083c83 | 189 | return t7_erase() |
Just4pLeisure | 3:92dae9083c83 | 190 | ? TERM_OK : TERM_ERR; |
Just4pLeisure | 4:682d96ff6d79 | 191 | // DUMP the T5 ECU BIN file stored in the FLASH chips |
Just4pLeisure | 4:682d96ff6d79 | 192 | case 'D': |
Just4pLeisure | 4:682d96ff6d79 | 193 | if (!t7_authenticate()) { |
Just4pLeisure | 4:682d96ff6d79 | 194 | if (!t7_initialise()) { |
Just4pLeisure | 4:682d96ff6d79 | 195 | printf("Trionic 7 Connection Failed\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 196 | return TERM_ERR; |
Just4pLeisure | 4:682d96ff6d79 | 197 | } |
Just4pLeisure | 4:682d96ff6d79 | 198 | if (!t7_authenticate()) { |
Just4pLeisure | 4:682d96ff6d79 | 199 | printf("Security Key Failed\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 200 | return TERM_ERR; |
Just4pLeisure | 4:682d96ff6d79 | 201 | } |
Just4pLeisure | 4:682d96ff6d79 | 202 | } |
Just4pLeisure | 3:92dae9083c83 | 203 | case 'd': |
Just4pLeisure | 3:92dae9083c83 | 204 | return t7_dump() |
Just4pLeisure | 3:92dae9083c83 | 205 | ? TERM_OK : TERM_ERR; |
Just4pLeisure | 4:682d96ff6d79 | 206 | // Send a FLASH update file to the T5 ECU |
Just4pLeisure | 4:682d96ff6d79 | 207 | case 'F': |
Just4pLeisure | 4:682d96ff6d79 | 208 | if (!t7_authenticate()) { |
Just4pLeisure | 4:682d96ff6d79 | 209 | if (!t7_initialise()) { |
Just4pLeisure | 4:682d96ff6d79 | 210 | printf("Trionic 7 Connection Failed\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 211 | return TERM_ERR; |
Just4pLeisure | 4:682d96ff6d79 | 212 | } |
Just4pLeisure | 4:682d96ff6d79 | 213 | if (!t7_authenticate()) { |
Just4pLeisure | 4:682d96ff6d79 | 214 | printf("Security Key Failed\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 215 | return TERM_ERR; |
Just4pLeisure | 4:682d96ff6d79 | 216 | } |
Just4pLeisure | 4:682d96ff6d79 | 217 | } |
Just4pLeisure | 4:682d96ff6d79 | 218 | if (!t7_erase()) { |
Just4pLeisure | 4:682d96ff6d79 | 219 | printf("Could not Erase FLASH!\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 220 | return TERM_ERR; |
Just4pLeisure | 4:682d96ff6d79 | 221 | } |
Just4pLeisure | 3:92dae9083c83 | 222 | case 'f': |
Just4pLeisure | 3:92dae9083c83 | 223 | return t7_flash() |
Just4pLeisure | 3:92dae9083c83 | 224 | ? TERM_OK : TERM_ERR; |
Just4pLeisure | 4:682d96ff6d79 | 225 | // Try to connect to CAN I-BUS |
Just4pLeisure | 4:682d96ff6d79 | 226 | case 'I' : |
Just4pLeisure | 4:682d96ff6d79 | 227 | printf("Trying to open CAN I-Bus (47619 Bit/s)...\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 228 | can_close(); |
Just4pLeisure | 4:682d96ff6d79 | 229 | //can_monitor(); |
Just4pLeisure | 4:682d96ff6d79 | 230 | can_set_speed(47619); |
Just4pLeisure | 4:682d96ff6d79 | 231 | can_open(); |
Just4pLeisure | 4:682d96ff6d79 | 232 | if (can_wait_timeout(T7ANYMSG, data, 8, T7CONNECTTIMEOUT)) { |
Just4pLeisure | 4:682d96ff6d79 | 233 | printf("Connected to Saab I-Bus\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 234 | //can_active(); |
Just4pLeisure | 4:682d96ff6d79 | 235 | return TERM_OK; |
Just4pLeisure | 4:682d96ff6d79 | 236 | } else { |
Just4pLeisure | 4:682d96ff6d79 | 237 | printf("I did not receive any I-Bus messages\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 238 | printf("FAILED to connect!\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 239 | return TERM_ERR; |
Just4pLeisure | 4:682d96ff6d79 | 240 | } |
Just4pLeisure | 4:682d96ff6d79 | 241 | // Try to connect to CAN P-BUS |
Just4pLeisure | 4:682d96ff6d79 | 242 | case 'P' : |
Just4pLeisure | 4:682d96ff6d79 | 243 | printf("Trying to open CAN P-Bus (500 kBit/s)...\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 244 | can_close(); |
Just4pLeisure | 4:682d96ff6d79 | 245 | //can_monitor(); |
Just4pLeisure | 4:682d96ff6d79 | 246 | can_set_speed(500000); |
Just4pLeisure | 4:682d96ff6d79 | 247 | can_open(); |
Just4pLeisure | 4:682d96ff6d79 | 248 | if (can_wait_timeout(T7ANYMSG, data, 8, T7CONNECTTIMEOUT)) { |
Just4pLeisure | 4:682d96ff6d79 | 249 | printf("Connected to Saab P-Bus\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 250 | //can_active(); |
Just4pLeisure | 4:682d96ff6d79 | 251 | return TERM_OK; |
Just4pLeisure | 4:682d96ff6d79 | 252 | } else { |
Just4pLeisure | 4:682d96ff6d79 | 253 | printf("I did not receive any P-Bus messages\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 254 | printf("FAILED to connect!\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 255 | return TERM_ERR; |
Just4pLeisure | 4:682d96ff6d79 | 256 | } |
Just4pLeisure | 3:92dae9083c83 | 257 | |
Just4pLeisure | 4:682d96ff6d79 | 258 | // Print help |
Just4pLeisure | 3:92dae9083c83 | 259 | case 'h': |
Just4pLeisure | 3:92dae9083c83 | 260 | t7_can_show_help(); |
Just4pLeisure | 3:92dae9083c83 | 261 | return TERM_OK; |
Just4pLeisure | 3:92dae9083c83 | 262 | case 'H': |
Just4pLeisure | 3:92dae9083c83 | 263 | t7_can_show_full_help(); |
Just4pLeisure | 3:92dae9083c83 | 264 | return TERM_OK; |
Just4pLeisure | 3:92dae9083c83 | 265 | default: |
Just4pLeisure | 3:92dae9083c83 | 266 | t7_can_show_help(); |
Just4pLeisure | 3:92dae9083c83 | 267 | break; |
Just4pLeisure | 3:92dae9083c83 | 268 | } |
Just4pLeisure | 4:682d96ff6d79 | 269 | // unknown command |
Just4pLeisure | 3:92dae9083c83 | 270 | return TERM_ERR; |
Just4pLeisure | 3:92dae9083c83 | 271 | } |
Just4pLeisure | 3:92dae9083c83 | 272 | |
Just4pLeisure | 3:92dae9083c83 | 273 | // |
Just4pLeisure | 3:92dae9083c83 | 274 | // Trionic7ShowHelp |
Just4pLeisure | 3:92dae9083c83 | 275 | // |
Just4pLeisure | 3:92dae9083c83 | 276 | // Displays a list of things that can be done with the T5 ECU. |
Just4pLeisure | 3:92dae9083c83 | 277 | // |
Just4pLeisure | 3:92dae9083c83 | 278 | // inputs: none |
Just4pLeisure | 3:92dae9083c83 | 279 | // return: none |
Just4pLeisure | 3:92dae9083c83 | 280 | // |
Just4pLeisure | 3:92dae9083c83 | 281 | void t7_can_show_help() { |
Just4pLeisure | 3:92dae9083c83 | 282 | printf("Trionic 7 Command Menu\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 283 | printf("======================\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 284 | printf("D - DUMP the T7 ECU FLASH to a file 'ORIGINAL.BIN'\r\n"); |
Just4pLeisure | 5:1775b4b13232 | 285 | printf("F - FLASH the update file 'MODIFIED.BIN' to the T7\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 286 | printf("\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 287 | printf("I - Try to open CAN I-Bus (47619 Bit/s)\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 288 | printf("P - Try to open CAN P-Bus (500 kBit/s)\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 289 | printf("\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 290 | printf("'ESC' - Return to Just4Trionic Main Menu\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 291 | printf("\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 292 | printf("h - Show this help menu\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 293 | printf("\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 294 | return; |
Just4pLeisure | 3:92dae9083c83 | 295 | } |
Just4pLeisure | 3:92dae9083c83 | 296 | // |
Just4pLeisure | 3:92dae9083c83 | 297 | // t7_can_show_full_help |
Just4pLeisure | 3:92dae9083c83 | 298 | // |
Just4pLeisure | 3:92dae9083c83 | 299 | // Displays a complete list of things that can be done with the T5 ECU. |
Just4pLeisure | 3:92dae9083c83 | 300 | // |
Just4pLeisure | 3:92dae9083c83 | 301 | // inputs: none |
Just4pLeisure | 3:92dae9083c83 | 302 | // return: none |
Just4pLeisure | 3:92dae9083c83 | 303 | // |
Just4pLeisure | 3:92dae9083c83 | 304 | void t7_can_show_full_help() { |
Just4pLeisure | 3:92dae9083c83 | 305 | printf("Trionic 7 Command Menu\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 306 | printf("======================\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 307 | printf("D - DUMP the T7 ECU FLASH to a file 'ORIGINAL.BIN'\r\n"); |
Just4pLeisure | 5:1775b4b13232 | 308 | printf("F - FLASH the update file 'MODIFIED.BIN' to the T7\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 309 | printf("\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 310 | printf("I - Try to open CAN I-Bus (47619 Bit/s)\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 311 | printf("P - Try to open CAN P-Bus (500 kBit/s)\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 312 | printf("\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 313 | printf("\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 314 | printf("i - Send initialisation message to T7\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 315 | printf("a - Send Authentication key to T7\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 316 | printf("d - Dump T7 Bin file 'ORIGINAL.BIN'\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 317 | printf("e - Erase the FLASH in the T7 ECU\r\n"); |
Just4pLeisure | 4:682d96ff6d79 | 318 | printf("f - FLASH the file 'MODIFIED.BIN' to the T7 ECU\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 319 | printf("\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 320 | printf("'ESC' - Return to Just4Trionic Main Menu\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 321 | printf("\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 322 | printf("H - Show this help menu\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 323 | printf("\r\n"); |
Just4pLeisure | 3:92dae9083c83 | 324 | return; |
Just4pLeisure | 3:92dae9083c83 | 325 | } |
Just4pLeisure | 3:92dae9083c83 | 326 | |
Just4pLeisure | 3:92dae9083c83 | 327 |