Sophie Dexter
/
Just4Trionic
Just4Trionic - CAN and BDM FLASH programmer for Saab cars
main.cpp@6:2fbcbebed28c, 2016-04-23 (annotated)
- Committer:
- Just4pLeisure
- Date:
- Sat Apr 23 18:31:40 2016 +0000
- Revision:
- 6:2fbcbebed28c
- Parent:
- 5:1775b4b13232
Version 1.6 Faster T7 P-BUS FLASHing algorithm, longer T8 erase timeout fixed BDM register display function
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Just4pLeisure | 0:e0b964252a05 | 1 | /******************************************************************************* |
Just4pLeisure | 0:e0b964252a05 | 2 | |
Just4pLeisure | 1:d5452e398b76 | 3 | Just4Trionic by Just4pLeisure |
Just4pLeisure | 0:e0b964252a05 | 4 | ***************************** |
Just4pLeisure | 1:d5452e398b76 | 5 | (c) 2010 by Sophie Dexter |
Just4pLeisure | 0:e0b964252a05 | 6 | |
Just4pLeisure | 0:e0b964252a05 | 7 | Whilst I have written this program myself I could not have done it without |
Just4pLeisure | 0:e0b964252a05 | 8 | a lot of help and the original ideas and programs written by: |
Just4pLeisure | 0:e0b964252a05 | 9 | Dilemma - Author of the Trionic Suite software programs and general Guru |
Just4pLeisure | 0:e0b964252a05 | 10 | http://trionic.mobixs.eu/ and http://www.ecuproject.com. |
Just4pLeisure | 0:e0b964252a05 | 11 | General Failure - Author of the T5CANlib software and regular contributor at |
Just4pLeisure | 0:e0b964252a05 | 12 | http://www.ecuproject.com. |
Just4pLeisure | 0:e0b964252a05 | 13 | Tomi Liljemark - Lots of information and programs about the Saab CAN bus |
Just4pLeisure | 0:e0b964252a05 | 14 | http://pikkupossu.1g.fi/tomi/projects/projects.html. |
Just4pLeisure | 0:e0b964252a05 | 15 | Scott Howard - Author of the BDM software. |
Just4pLeisure | 1:d5452e398b76 | 16 | Janis Silins - Valued contributor at http://www.ecuproject.com and creator of |
Just4pLeisure | 1:d5452e398b76 | 17 | USBBDM. For sharing his BDM software (which also had a very useful method of |
Just4pLeisure | 1:d5452e398b76 | 18 | entering commands) |
Just4pLeisure | 1:d5452e398b76 | 19 | Plus inspiration and ideas from many others... |
Just4pLeisure | 0:e0b964252a05 | 20 | |
Just4pLeisure | 0:e0b964252a05 | 21 | Sophie x |
Just4pLeisure | 0:e0b964252a05 | 22 | |
Just4pLeisure | 0:e0b964252a05 | 23 | ******************************************************************************** |
Just4pLeisure | 0:e0b964252a05 | 24 | |
Just4pLeisure | 0:e0b964252a05 | 25 | WARNING: Use at your own risk, sadly this software comes with no guarantees. |
Just4pLeisure | 0:e0b964252a05 | 26 | This software is provided 'free' and in good faith, but the author does not |
Just4pLeisure | 0:e0b964252a05 | 27 | accept liability for any damage arising from its use. |
Just4pLeisure | 0:e0b964252a05 | 28 | |
Just4pLeisure | 0:e0b964252a05 | 29 | ******************************************************************************** |
Just4pLeisure | 0:e0b964252a05 | 30 | |
Just4pLeisure | 6:2fbcbebed28c | 31 | Version 1.6 (04/2016) |
Just4pLeisure | 6:2fbcbebed28c | 32 | |
Just4pLeisure | 6:2fbcbebed28c | 33 | Fixed since Version 1.5: |
Just4pLeisure | 6:2fbcbebed28c | 34 | BDM |
Just4pLeisure | 6:2fbcbebed28c | 35 | Improvements to CPU register content display |
Just4pLeisure | 6:2fbcbebed28c | 36 | T8 erase timeout period to 200 seconds (was incorrectly only 20 seconds) |
Just4pLeisure | 6:2fbcbebed28c | 37 | |
Just4pLeisure | 6:2fbcbebed28c | 38 | Added since Version 1.5: |
Just4pLeisure | 6:2fbcbebed28c | 39 | T7 CAN functions: |
Just4pLeisure | 6:2fbcbebed28c | 40 | Separate FLASHing algorithms for I and P-BUS connections |
Just4pLeisure | 6:2fbcbebed28c | 41 | Completely safe, but slow, I-BUS algorithm |
Just4pLeisure | 6:2fbcbebed28c | 42 | Pseudo 'recovery' FLASHing function can be used to retry a failed |
Just4pLeisure | 6:2fbcbebed28c | 43 | FLASH with safe, slow algorithm |
Just4pLeisure | 6:2fbcbebed28c | 44 | |
Just4pLeisure | 6:2fbcbebed28c | 45 | Changes since Version 1.5: |
Just4pLeisure | 6:2fbcbebed28c | 46 | Additional debug messages |
Just4pLeisure | 6:2fbcbebed28c | 47 | T7 CAN functions: |
Just4pLeisure | 6:2fbcbebed28c | 48 | Code refactoring to make file handling simpler |
Just4pLeisure | 6:2fbcbebed28c | 49 | |
Just4pLeisure | 5:1775b4b13232 | 50 | Version 1.5 (04/2015) |
Just4pLeisure | 5:1775b4b13232 | 51 | |
Just4pLeisure | 5:1775b4b13232 | 52 | Added since Version 1.4 |
Just4pLeisure | 5:1775b4b13232 | 53 | T8 CAN functions: DUMP, FLASH and RECOVERY |
Just4pLeisure | 5:1775b4b13232 | 54 | Using modified T8Bootloaders that are slightly faster :-) |
Just4pLeisure | 5:1775b4b13232 | 55 | Algorithms for different types of 5 volt replacement FLASH Chips in T5 ECUs |
Just4pLeisure | 5:1775b4b13232 | 56 | AMD, ST and AMIC 29F010 types |
Just4pLeisure | 5:1775b4b13232 | 57 | SST 39F010 |
Just4pLeisure | 5:1775b4b13232 | 58 | ATMEL 29C512 and 29C010 |
Just4pLeisure | 5:1775b4b13232 | 59 | |
Just4pLeisure | 5:1775b4b13232 | 60 | Changes since Version 1.4 |
Just4pLeisure | 5:1775b4b13232 | 61 | BDM FLASHing uses BD32 like Target Resident Drivers. |
Just4pLeisure | 5:1775b4b13232 | 62 | Based on my 'universal scripts' |
Just4pLeisure | 5:1775b4b13232 | 63 | BDM FLASHing much faster now |
Just4pLeisure | 5:1775b4b13232 | 64 | Always use slow BDM clock function (bdm_clk_slow) for reliability |
Just4pLeisure | 5:1775b4b13232 | 65 | Even when using the slow method it only takes 8 seconds |
Just4pLeisure | 5:1775b4b13232 | 66 | longer to FLASH a T8 ECU. |
Just4pLeisure | 5:1775b4b13232 | 67 | mbed library and compiler changes make it difficult to |
Just4pLeisure | 5:1775b4b13232 | 68 | maintain the faster bdm functions that rely on software |
Just4pLeisure | 5:1775b4b13232 | 69 | delay loops for timing. |
Just4pLeisure | 5:1775b4b13232 | 70 | The file extension of the file to be FLASHed is now the more usual 'BIN'. |
Just4pLeisure | 5:1775b4b13232 | 71 | i.e. 'modified.bin' instead of 'modified.hex' |
Just4pLeisure | 5:1775b4b13232 | 72 | |
Just4pLeisure | 5:1775b4b13232 | 73 | ******************************************************************************** |
Just4pLeisure | 5:1775b4b13232 | 74 | |
Just4pLeisure | 4:682d96ff6d79 | 75 | Version 1.4 (07/2013) |
Just4pLeisure | 4:682d96ff6d79 | 76 | |
Just4pLeisure | 5:1775b4b13232 | 77 | Added since Verion 1.3 |
Just4pLeisure | 4:682d96ff6d79 | 78 | Progress indication shown as a percentage, slightly slower but more informative |
Just4pLeisure | 4:682d96ff6d79 | 79 | T8 BDM Functionality |
Just4pLeisure | 4:682d96ff6d79 | 80 | |
Just4pLeisure | 4:682d96ff6d79 | 81 | Changes since Verion 1.3 |
Just4pLeisure | 4:682d96ff6d79 | 82 | T7 CAN FLASH algorithm changed to only send 4 Bytes at a time |
Just4pLeisure | 4:682d96ff6d79 | 83 | Slightly slower but more reliable especially with I-Bus connection |
Just4pLeisure | 4:682d96ff6d79 | 84 | |
Just4pLeisure | 4:682d96ff6d79 | 85 | ******************************************************************************** |
Just4pLeisure | 4:682d96ff6d79 | 86 | |
Just4pLeisure | 3:92dae9083c83 | 87 | Version 1.3 (06/2011) - Basic T7 CAN support and faster T5 CAN bootloader |
Just4pLeisure | 3:92dae9083c83 | 88 | |
Just4pLeisure | 4:682d96ff6d79 | 89 | Changes since Verion 1.2 |
Just4pLeisure | 3:92dae9083c83 | 90 | New T7 CAN menu provides some very basic T7 CAN DUMP and FLASH functions |
Just4pLeisure | 3:92dae9083c83 | 91 | T5 CAN uses Mybooty version 2 for 1 Mbps CAN speed |
Just4pLeisure | 3:92dae9083c83 | 92 | Get MyBooty version 2.x from forum.ecuproject.com |
Just4pLeisure | 3:92dae9083c83 | 93 | Does not work with version MyBooty 1.x |
Just4pLeisure | 3:92dae9083c83 | 94 | |
Just4pLeisure | 3:92dae9083c83 | 95 | ******************************************************************************** |
Just4pLeisure | 3:92dae9083c83 | 96 | |
Just4pLeisure | 2:bf3a2b29259a | 97 | Version 1.2 (12/2010) - Only a very small update |
Just4pLeisure | 2:bf3a2b29259a | 98 | |
Just4pLeisure | 2:bf3a2b29259a | 99 | Fixed since Version 1.1: |
Just4pLeisure | 2:bf3a2b29259a | 100 | My method of detecting the FLASH type didn't work for T7 ECUs |
Just4pLeisure | 2:bf3a2b29259a | 101 | Now that that I have corrected this bug it is possible to |
Just4pLeisure | 2:bf3a2b29259a | 102 | FLASH Trionic 7 ECUs using the BDM connection |
Just4pLeisure | 2:bf3a2b29259a | 103 | See the 'get_flash_id' function in bdmtrionic.cpp |
Just4pLeisure | 2:bf3a2b29259a | 104 | |
Just4pLeisure | 3:92dae9083c83 | 105 | Changes since Verion 1.1 |
Just4pLeisure | 2:bf3a2b29259a | 106 | I have removed everything to do with the BDM DS connection |
Just4pLeisure | 2:bf3a2b29259a | 107 | I have changed the mbed pin number for the BDM DSO connection |
Just4pLeisure | 2:bf3a2b29259a | 108 | Now all BDM connections are part of the same MBED 'port' |
Just4pLeisure | 2:bf3a2b29259a | 109 | Being part of one port makes it possible to change all |
Just4pLeisure | 2:bf3a2b29259a | 110 | connections simulataneously so speeding up BDM |
Just4pLeisure | 2:bf3a2b29259a | 111 | See 'interfaces.cpp' for details of how the mbed pins connect. |
Just4pLeisure | 2:bf3a2b29259a | 112 | Uglybug's wiring circuit has these connections (thanks Uglybug) |
Just4pLeisure | 2:bf3a2b29259a | 113 | |
Just4pLeisure | 2:bf3a2b29259a | 114 | ******************************************************************************** |
Just4pLeisure | 2:bf3a2b29259a | 115 | |
Just4pLeisure | 1:d5452e398b76 | 116 | Version 1.1 (09/2010) - Still very crude way of doing things |
Just4pLeisure | 1:d5452e398b76 | 117 | |
Just4pLeisure | 1:d5452e398b76 | 118 | Additions since Version 1: |
Just4pLeisure | 1:d5452e398b76 | 119 | The BDM interface is now working |
Just4pLeisure | 1:d5452e398b76 | 120 | Based on Janis Silin's BDM software with modifications and additions |
Just4pLeisure | 1:d5452e398b76 | 121 | Detect which type of FLASH chip is fitted to work out type of ECU |
Just4pLeisure | 1:d5452e398b76 | 122 | Modifications to FLASH algorithms - I think my algorithms are |
Just4pLeisure | 1:d5452e398b76 | 123 | closer to the datasheet methods. Still to do: |
Just4pLeisure | 1:d5452e398b76 | 124 | Separate pulse counters for 28Fxxx erase |
Just4pLeisure | 1:d5452e398b76 | 125 | DQ7 and DQ5 checking method for 29Fxxx FLASH |
Just4pLeisure | 1:d5452e398b76 | 126 | Works for T5.5 ECUs with 28F010 and 29F010 chips |
Just4pLeisure | 1:d5452e398b76 | 127 | Probably works with T5.2 ECUs (chip detection method) |
Just4pLeisure | 1:d5452e398b76 | 128 | MAY work with T7 ECUs ('prep' method may need changes - I can't test T7) |
Just4pLeisure | 1:d5452e398b76 | 129 | NOTE: Some of Janis' original BDM commands may not work, or at least |
Just4pLeisure | 1:d5452e398b76 | 130 | not as originally intended |
Just4pLeisure | 1:d5452e398b76 | 131 | Lawicell CAN232 interface partially working |
Just4pLeisure | 1:d5452e398b76 | 132 | Only a few Lawicell message types to open/close, set speed and write |
Just4pLeisure | 1:d5452e398b76 | 133 | Trionic5 CAN functions |
Just4pLeisure | 1:d5452e398b76 | 134 | All-in-one 'D' and 'F' commands to DUMP and FLASH BIN files |
Just4pLeisure | 1:d5452e398b76 | 135 | Lots of checking for errors, either works or says it failed |
Just4pLeisure | 1:d5452e398b76 | 136 | No need to interpret the cryptic CAN messages anymore |
Just4pLeisure | 1:d5452e398b76 | 137 | Should now work for T5.2 and T5.5 ECUs |
Just4pLeisure | 1:d5452e398b76 | 138 | Detects FLASH chip type and works out which ECU is connected T5.2/5.5 |
Just4pLeisure | 1:d5452e398b76 | 139 | |
Just4pLeisure | 1:d5452e398b76 | 140 | ******************************************************************************** |
Just4pLeisure | 1:d5452e398b76 | 141 | |
Just4pLeisure | 1:d5452e398b76 | 142 | Version 1 (04/2010)- The basic CAN functions are working |
Just4pLeisure | 0:e0b964252a05 | 143 | |
Just4pLeisure | 0:e0b964252a05 | 144 | I have decided to 'release' this software somewhat prematurely because the FLASH |
Just4pLeisure | 0:e0b964252a05 | 145 | chips in my spare ECU have 'died' and I don't know when I will be able to do |
Just4pLeisure | 0:e0b964252a05 | 146 | carry on improving and 'polishing' it. This way others will be able to use and |
Just4pLeisure | 0:e0b964252a05 | 147 | enhance it without having to wait for me. |
Just4pLeisure | 0:e0b964252a05 | 148 | |
Just4pLeisure | 0:e0b964252a05 | 149 | For now, only option '5' Trionic ECU CAN interface is working. BDM and Lawicell |
Just4pLeisure | 0:e0b964252a05 | 150 | CAN232 functions are dummies. The intention is to build a complete suite of CAN |
Just4pLeisure | 0:e0b964252a05 | 151 | software for Trionic5, 7 and 8 ECU types as well as adding a BDM interface to |
Just4pLeisure | 0:e0b964252a05 | 152 | make an 'all-in-one' USB programming tool. |
Just4pLeisure | 0:e0b964252a05 | 153 | |
Just4pLeisure | 0:e0b964252a05 | 154 | To make this you will need an mbed system and the CAN circuit from this page: |
Just4pLeisure | 0:e0b964252a05 | 155 | http://mbed.org/projects/cookbook/wiki/CanBusExample1 |
Just4pLeisure | 0:e0b964252a05 | 156 | |
Just4pLeisure | 0:e0b964252a05 | 157 | Some ideas for the truly creative and adventurous of you is to make a gizmo that |
Just4pLeisure | 0:e0b964252a05 | 158 | doesn't even need to be connected to a laptop or PC to use, maybe even a self- |
Just4pLeisure | 0:e0b964252a05 | 159 | contained vesion of Dilemma's CarPC using ideas from this pages: |
Just4pLeisure | 0:e0b964252a05 | 160 | |
Just4pLeisure | 0:e0b964252a05 | 161 | http://mbed.org/projects/cookbook/wiki/PS2Keyboard |
Just4pLeisure | 0:e0b964252a05 | 162 | http://mbed.org/projects/cookbook/wiki/PS2Mouse |
Just4pLeisure | 0:e0b964252a05 | 163 | http://mbed.org/projects/cookbook/wiki/MobileLCD |
Just4pLeisure | 0:e0b964252a05 | 164 | http://mbed.org/projects/cookbook/wiki/SDCard |
Just4pLeisure | 0:e0b964252a05 | 165 | |
Just4pLeisure | 0:e0b964252a05 | 166 | *******************************************************************************/ |
Just4pLeisure | 0:e0b964252a05 | 167 | |
Just4pLeisure | 0:e0b964252a05 | 168 | #include "mbed.h" |
Just4pLeisure | 1:d5452e398b76 | 169 | // |
Just4pLeisure | 1:d5452e398b76 | 170 | #include "common.h" |
Just4pLeisure | 1:d5452e398b76 | 171 | #include "bdm.h" |
Just4pLeisure | 1:d5452e398b76 | 172 | #include "can232.h" |
Just4pLeisure | 1:d5452e398b76 | 173 | #include "t5can.h" |
Just4pLeisure | 3:92dae9083c83 | 174 | #include "t7can.h" |
Just4pLeisure | 4:682d96ff6d79 | 175 | #include "t8can.h" |
Just4pLeisure | 0:e0b964252a05 | 176 | |
Just4pLeisure | 1:d5452e398b76 | 177 | // constants |
Just4pLeisure | 1:d5452e398b76 | 178 | #define CMD_BUF_LENGTH 32 ///< command buffer size |
Just4pLeisure | 0:e0b964252a05 | 179 | |
Just4pLeisure | 1:d5452e398b76 | 180 | // static variables |
Just4pLeisure | 1:d5452e398b76 | 181 | static char cmd_buffer[CMD_BUF_LENGTH]; ///< command string buffer |
Just4pLeisure | 0:e0b964252a05 | 182 | |
Just4pLeisure | 1:d5452e398b76 | 183 | // private functions |
Just4pLeisure | 1:d5452e398b76 | 184 | uint8_t execute_just4trionic_cmd(); |
Just4pLeisure | 1:d5452e398b76 | 185 | void show_just4trionic_help(); |
Just4pLeisure | 0:e0b964252a05 | 186 | |
Just4pLeisure | 4:682d96ff6d79 | 187 | int main() |
Just4pLeisure | 4:682d96ff6d79 | 188 | { |
Just4pLeisure | 0:e0b964252a05 | 189 | // fast serial speed |
Just4pLeisure | 4:682d96ff6d79 | 190 | //pc.baud(921600); |
Just4pLeisure | 0:e0b964252a05 | 191 | pc.baud(115200); |
Just4pLeisure | 1:d5452e398b76 | 192 | |
Just4pLeisure | 1:d5452e398b76 | 193 | // the address of the function to be attached (leds_off) and the interval (0.1 seconds) |
Just4pLeisure | 1:d5452e398b76 | 194 | // This 'ticker' turns off the activity LEDs so that they don't stay on if something has gone wrong |
Just4pLeisure | 1:d5452e398b76 | 195 | ticker.attach(&leds_off, 0.1); |
Just4pLeisure | 1:d5452e398b76 | 196 | |
Just4pLeisure | 1:d5452e398b76 | 197 | // clear incoming buffer |
Just4pLeisure | 1:d5452e398b76 | 198 | // sometimes TeraTerm gets 'confused'. johnc does this in his code |
Just4pLeisure | 1:d5452e398b76 | 199 | // hopefully this will fix the problem |
Just4pLeisure | 1:d5452e398b76 | 200 | // unfortunately it doesn't, but it seems like a good idea |
Just4pLeisure | 1:d5452e398b76 | 201 | char rx_char; |
Just4pLeisure | 1:d5452e398b76 | 202 | while (pc.readable()) |
Just4pLeisure | 1:d5452e398b76 | 203 | rx_char = pc.getc(); |
Just4pLeisure | 1:d5452e398b76 | 204 | |
Just4pLeisure | 1:d5452e398b76 | 205 | show_just4trionic_help(); |
Just4pLeisure | 1:d5452e398b76 | 206 | |
Just4pLeisure | 1:d5452e398b76 | 207 | // main loop |
Just4pLeisure | 1:d5452e398b76 | 208 | *cmd_buffer = '\0'; |
Just4pLeisure | 1:d5452e398b76 | 209 | char ret; |
Just4pLeisure | 1:d5452e398b76 | 210 | while (true) { |
Just4pLeisure | 1:d5452e398b76 | 211 | // read chars from USB |
Just4pLeisure | 1:d5452e398b76 | 212 | // send received messages to the pc over USB connection |
Just4pLeisure | 1:d5452e398b76 | 213 | // This function displays any CAN messages that are 'missed' by the other functions |
Just4pLeisure | 1:d5452e398b76 | 214 | // Can messages might be 'missed' because they are received after a 'timeout' period |
Just4pLeisure | 1:d5452e398b76 | 215 | // or because they weren't expected, e.g. if the T5 ECU resets for some reason |
Just4pLeisure | 1:d5452e398b76 | 216 | t5_can_show_can_message(); |
Just4pLeisure | 1:d5452e398b76 | 217 | if (pc.readable()) { |
Just4pLeisure | 1:d5452e398b76 | 218 | // turn Error LED off for next command |
Just4pLeisure | 1:d5452e398b76 | 219 | led4 = 0; |
Just4pLeisure | 1:d5452e398b76 | 220 | rx_char = pc.getc(); |
Just4pLeisure | 1:d5452e398b76 | 221 | switch (rx_char) { |
Just4pLeisure | 1:d5452e398b76 | 222 | // end-of-command reached |
Just4pLeisure | 1:d5452e398b76 | 223 | case TERM_OK : |
Just4pLeisure | 1:d5452e398b76 | 224 | // execute command and return flag via USB |
Just4pLeisure | 1:d5452e398b76 | 225 | timer.reset(); |
Just4pLeisure | 1:d5452e398b76 | 226 | timer.start(); |
Just4pLeisure | 1:d5452e398b76 | 227 | ret = execute_just4trionic_cmd(); |
Just4pLeisure | 1:d5452e398b76 | 228 | show_just4trionic_help(); |
Just4pLeisure | 1:d5452e398b76 | 229 | pc.putc(ret); |
Just4pLeisure | 1:d5452e398b76 | 230 | // reset command buffer |
Just4pLeisure | 1:d5452e398b76 | 231 | *cmd_buffer = '\0'; |
Just4pLeisure | 1:d5452e398b76 | 232 | // light up LED |
Just4pLeisure | 1:d5452e398b76 | 233 | // ret == TERM_OK ? led_on(LED_ACT) : led_on(LED_ERR); |
Just4pLeisure | 1:d5452e398b76 | 234 | ret == TERM_OK ? led3 = 1 : led4 = 1; |
Just4pLeisure | 1:d5452e398b76 | 235 | break; |
Just4pLeisure | 1:d5452e398b76 | 236 | // another command char |
Just4pLeisure | 1:d5452e398b76 | 237 | default: |
Just4pLeisure | 1:d5452e398b76 | 238 | // store in buffer if space permits |
Just4pLeisure | 1:d5452e398b76 | 239 | if (StrLen(cmd_buffer) < CMD_BUF_LENGTH - 1) { |
Just4pLeisure | 1:d5452e398b76 | 240 | StrAddc(cmd_buffer, rx_char); |
Just4pLeisure | 1:d5452e398b76 | 241 | } |
Just4pLeisure | 1:d5452e398b76 | 242 | break; |
Just4pLeisure | 1:d5452e398b76 | 243 | } |
Just4pLeisure | 1:d5452e398b76 | 244 | } |
Just4pLeisure | 0:e0b964252a05 | 245 | } |
Just4pLeisure | 0:e0b964252a05 | 246 | } |
Just4pLeisure | 0:e0b964252a05 | 247 | |
Just4pLeisure | 1:d5452e398b76 | 248 | //----------------------------------------------------------------------------- |
Just4pLeisure | 1:d5452e398b76 | 249 | /** |
Just4pLeisure | 1:d5452e398b76 | 250 | Executes a command and returns result flag (does not transmit the flag |
Just4pLeisure | 1:d5452e398b76 | 251 | itself). |
Just4pLeisure | 1:d5452e398b76 | 252 | |
Just4pLeisure | 1:d5452e398b76 | 253 | @return command flag (success / failure) |
Just4pLeisure | 1:d5452e398b76 | 254 | */ |
Just4pLeisure | 4:682d96ff6d79 | 255 | uint8_t execute_just4trionic_cmd() |
Just4pLeisure | 4:682d96ff6d79 | 256 | { |
Just4pLeisure | 1:d5452e398b76 | 257 | |
Just4pLeisure | 1:d5452e398b76 | 258 | |
Just4pLeisure | 1:d5452e398b76 | 259 | // uint8_t cmd_length = strlen(cmd_buffer); |
Just4pLeisure | 1:d5452e398b76 | 260 | // command groups |
Just4pLeisure | 1:d5452e398b76 | 261 | switch (*cmd_buffer) { |
Just4pLeisure | 1:d5452e398b76 | 262 | // CHECK_ARGLENGTH(0); |
Just4pLeisure | 1:d5452e398b76 | 263 | case 'b': |
Just4pLeisure | 1:d5452e398b76 | 264 | case 'B': |
Just4pLeisure | 1:d5452e398b76 | 265 | bdm(); |
Just4pLeisure | 1:d5452e398b76 | 266 | return TERM_OK; |
Just4pLeisure | 1:d5452e398b76 | 267 | case 'o': |
Just4pLeisure | 1:d5452e398b76 | 268 | case 'O': |
Just4pLeisure | 1:d5452e398b76 | 269 | can232(); |
Just4pLeisure | 1:d5452e398b76 | 270 | return TERM_OK; |
Just4pLeisure | 1:d5452e398b76 | 271 | case '5': |
Just4pLeisure | 1:d5452e398b76 | 272 | t5_can(); |
Just4pLeisure | 1:d5452e398b76 | 273 | return TERM_OK; |
Just4pLeisure | 3:92dae9083c83 | 274 | case '7': |
Just4pLeisure | 3:92dae9083c83 | 275 | t7_can(); |
Just4pLeisure | 3:92dae9083c83 | 276 | return TERM_OK; |
Just4pLeisure | 4:682d96ff6d79 | 277 | case '8': |
Just4pLeisure | 4:682d96ff6d79 | 278 | t8_can(); |
Just4pLeisure | 4:682d96ff6d79 | 279 | return TERM_OK; |
Just4pLeisure | 1:d5452e398b76 | 280 | case 'h': |
Just4pLeisure | 1:d5452e398b76 | 281 | case 'H': |
Just4pLeisure | 1:d5452e398b76 | 282 | return TERM_OK; |
Just4pLeisure | 1:d5452e398b76 | 283 | default: |
Just4pLeisure | 1:d5452e398b76 | 284 | break; |
Just4pLeisure | 1:d5452e398b76 | 285 | } |
Just4pLeisure | 1:d5452e398b76 | 286 | |
Just4pLeisure | 1:d5452e398b76 | 287 | // unknown command |
Just4pLeisure | 1:d5452e398b76 | 288 | return TERM_ERR; |
Just4pLeisure | 1:d5452e398b76 | 289 | } |
Just4pLeisure | 1:d5452e398b76 | 290 | |
Just4pLeisure | 4:682d96ff6d79 | 291 | void show_just4trionic_help() |
Just4pLeisure | 4:682d96ff6d79 | 292 | { |
Just4pLeisure | 6:2fbcbebed28c | 293 | #ifdef DEBUG |
Just4pLeisure | 6:2fbcbebed28c | 294 | printf("*************************\r\n"); |
Just4pLeisure | 6:2fbcbebed28c | 295 | printf("** D E B U G B U I L D **\r\n"); |
Just4pLeisure | 6:2fbcbebed28c | 296 | printf("*************************\r\n"); |
Just4pLeisure | 6:2fbcbebed28c | 297 | #endif |
Just4pLeisure | 6:2fbcbebed28c | 298 | printf("=========================\r\n"); |
Just4pLeisure | 6:2fbcbebed28c | 299 | printf("Just4Trionic Release %d.%d\r\n", FW_VERSION_MAJOR, FW_VERSION_MINOR); |
Just4pLeisure | 0:e0b964252a05 | 300 | printf("=========================\r\n"); |
Just4pLeisure | 6:2fbcbebed28c | 301 | printf("Modes Menu\r\n"); |
Just4pLeisure | 6:2fbcbebed28c | 302 | printf("=========================\r\n"); |
Just4pLeisure | 6:2fbcbebed28c | 303 | printf("b/B - Enter BDM mode\r\n"); |
Just4pLeisure | 6:2fbcbebed28c | 304 | printf("o/O - Enter Lawicel CAN mode\r\n"); |
Just4pLeisure | 6:2fbcbebed28c | 305 | printf("5 - Enter Trionic5 CAN mode\r\n"); |
Just4pLeisure | 6:2fbcbebed28c | 306 | printf("7 - Enter Trionic7 CAN mode\r\n"); |
Just4pLeisure | 6:2fbcbebed28c | 307 | printf("8 - Enter Trionic8 CAN mode\r\n"); |
Just4pLeisure | 0:e0b964252a05 | 308 | printf("\r\n"); |
Just4pLeisure | 0:e0b964252a05 | 309 | printf("h/H - show this help menu\r\n"); |
Just4pLeisure | 1:d5452e398b76 | 310 | printf("\r\n"); |
Just4pLeisure | 0:e0b964252a05 | 311 | return; |
Just4pLeisure | 1:d5452e398b76 | 312 | } |