Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbed-STM32F103C8T6
ecu_simulator.h@7:467e350d1a10, 2020-06-10 (annotated)
- Committer:
- RogerJKelly
- Date:
- Wed Jun 10 20:15:48 2020 +0000
- Revision:
- 7:467e350d1a10
- Parent:
- 6:41a4ad385daa
RIXEN SIM with Maple Mini
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pangsk | 6:41a4ad385daa | 1 | #ifndef ECU_SIMULATOR_H |
| pangsk | 6:41a4ad385daa | 2 | #define ECU_SIMULATOR_H |
| pangsk | 0:908be729d27c | 3 | |
| RogerJKelly | 7:467e350d1a10 | 4 | //#define CANSPEED_125 125000 // CAN speed at 125 kbps |
| RogerJKelly | 7:467e350d1a10 | 5 | //#define CANSPEED_250 250000 // CAN speed at 250 kbps |
| pangsk | 0:908be729d27c | 6 | #define CANSPEED_500 500000 // CAN speed at 500 kbps |
| pangsk | 0:908be729d27c | 7 | |
| pangsk | 0:908be729d27c | 8 | /* Details from http://en.wikipedia.org/wiki/OBD-II_PIDs */ |
| pangsk | 6:41a4ad385daa | 9 | #define MODE1 0x01 //Show current data |
| pangsk | 6:41a4ad385daa | 10 | #define MODE2 0x02 //Show freeze frame data |
| pangsk | 6:41a4ad385daa | 11 | #define MODE3 0x03 //Show stored Diagnostic Trouble Codes |
| pangsk | 6:41a4ad385daa | 12 | #define MODE4 0x04 //Clear Diagnostic Trouble Codes and stored values |
| pangsk | 6:41a4ad385daa | 13 | |
| pangsk | 6:41a4ad385daa | 14 | #define PID_SUPPORTED 0x00 |
| pangsk | 6:41a4ad385daa | 15 | #define MONITOR_STATUS 0x01 |
| pangsk | 0:908be729d27c | 16 | #define ENGINE_COOLANT_TEMP 0x05 |
| pangsk | 0:908be729d27c | 17 | #define ENGINE_RPM 0x0C |
| pangsk | 0:908be729d27c | 18 | #define VEHICLE_SPEED 0x0D |
| pangsk | 0:908be729d27c | 19 | #define MAF_SENSOR 0x10 |
| pangsk | 0:908be729d27c | 20 | #define THROTTLE 0x11 |
| pangsk | 0:908be729d27c | 21 | #define O2_VOLTAGE 0x14 |
| pangsk | 0:908be729d27c | 22 | |
| pangsk | 6:41a4ad385daa | 23 | #define MODE1_RESPONSE 0x41 |
| pangsk | 6:41a4ad385daa | 24 | #define MODE3_RESPONSE 0x43 |
| pangsk | 6:41a4ad385daa | 25 | #define MODE4_RESPONSE 0x44 |
| pangsk | 0:908be729d27c | 26 | #define PID_REQUEST 0x7DF |
| pangsk | 0:908be729d27c | 27 | #define PID_REPLY 0x7E8 |
| pangsk | 0:908be729d27c | 28 | |
| RogerJKelly | 7:467e350d1a10 | 29 | #define ESPAR_CMD 0x7A0 // COMMAND ID |
| RogerJKelly | 7:467e350d1a10 | 30 | #define ESPAR_RES 0x73C // response id |
| RogerJKelly | 7:467e350d1a10 | 31 | |
| RogerJKelly | 7:467e350d1a10 | 32 | typedef struct{ |
| pangsk | 6:41a4ad385daa | 33 | unsigned char coolant_temp; |
| pangsk | 6:41a4ad385daa | 34 | unsigned int engine_rpm; |
| pangsk | 6:41a4ad385daa | 35 | unsigned char throttle_position; |
| pangsk | 6:41a4ad385daa | 36 | unsigned char vehicle_speed; |
| pangsk | 6:41a4ad385daa | 37 | unsigned int maf_airflow; |
| pangsk | 6:41a4ad385daa | 38 | unsigned int o2_voltage; |
| pangsk | 6:41a4ad385daa | 39 | unsigned char dtc; |
| RogerJKelly | 7:467e350d1a10 | 40 | unsigned char active_fault; |
| pangsk | 6:41a4ad385daa | 41 | }ecu_t; |
| pangsk | 6:41a4ad385daa | 42 | |
| pangsk | 6:41a4ad385daa | 43 | extern ecu_t ecu; |
| pangsk | 6:41a4ad385daa | 44 | |
| pangsk | 0:908be729d27c | 45 | namespace mbed { |
| pangsk | 0:908be729d27c | 46 | |
| pangsk | 6:41a4ad385daa | 47 | class ecu_sim{ |
| pangsk | 0:908be729d27c | 48 | |
| pangsk | 6:41a4ad385daa | 49 | public: |
| pangsk | 0:908be729d27c | 50 | |
| pangsk | 6:41a4ad385daa | 51 | ecu_sim(int can_speed); |
| pangsk | 6:41a4ad385daa | 52 | void canspeed(int can_speed); |
| pangsk | 6:41a4ad385daa | 53 | unsigned char request(void); |
| pangsk | 6:41a4ad385daa | 54 | |
| pangsk | 6:41a4ad385daa | 55 | private: |
| pangsk | 0:908be729d27c | 56 | |
| pangsk | 6:41a4ad385daa | 57 | int i; |
| pangsk | 6:41a4ad385daa | 58 | |
| pangsk | 6:41a4ad385daa | 59 | }; |
| pangsk | 6:41a4ad385daa | 60 | } |
| pangsk | 0:908be729d27c | 61 | |
| pangsk | 0:908be729d27c | 62 | |
| pangsk | 0:908be729d27c | 63 | |
| pangsk | 0:908be729d27c | 64 | #endif |