CAN-Bus ECU simulator. Only part of the SAE J1979 are implemented. Uses CAN-Bus demo board as hardware platform. http://skpang.co.uk/catalog/canbus-ecu-simulator-with-lpc1768-module-p-1400.html Useful for testing diagnostic tools.
Fork of ecu_reader by
ecu_simulator.h
00001 #ifndef ECU_SIMULATOR_H 00002 #define ECU_SIMULATOR_H 00003 00004 #define CANSPEED_125 125000 // CAN speed at 125 kbps 00005 #define CANSPEED_250 250000 // CAN speed at 250 kbps 00006 #define CANSPEED_500 500000 // CAN speed at 500 kbps 00007 00008 /* Details from http://en.wikipedia.org/wiki/OBD-II_PIDs */ 00009 #define MODE1 0x01 //Show current data 00010 #define MODE2 0x02 //Show freeze frame data 00011 #define MODE3 0x03 //Show stored Diagnostic Trouble Codes 00012 #define MODE4 0x04 //Clear Diagnostic Trouble Codes and stored values 00013 00014 #define PID_SUPPORTED 0x00 00015 #define MONITOR_STATUS 0x01 00016 #define ENGINE_COOLANT_TEMP 0x05 00017 #define ENGINE_RPM 0x0C 00018 #define VEHICLE_SPEED 0x0D 00019 #define MAF_SENSOR 0x10 00020 #define THROTTLE 0x11 00021 #define O2_VOLTAGE 0x14 00022 00023 #define MODE1_RESPONSE 0x41 00024 #define MODE3_RESPONSE 0x43 00025 #define MODE4_RESPONSE 0x44 00026 #define PID_REQUEST 0x7DF 00027 #define PID_REPLY 0x7E8 00028 00029 typedef struct{ 00030 00031 unsigned char coolant_temp; 00032 unsigned int engine_rpm; 00033 unsigned char throttle_position; 00034 unsigned char vehicle_speed; 00035 unsigned int maf_airflow; 00036 unsigned int o2_voltage; 00037 unsigned char dtc; 00038 00039 }ecu_t; 00040 00041 extern ecu_t ecu; 00042 00043 namespace mbed { 00044 00045 class ecu_sim{ 00046 00047 public: 00048 00049 ecu_sim(int can_speed); 00050 void canspeed(int can_speed); 00051 unsigned char request(void); 00052 00053 private: 00054 00055 int i; 00056 00057 }; 00058 } 00059 00060 00061 00062 #endif
Generated on Wed Jul 13 2022 23:36:48 by 1.7.2