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.
Fork of CAN_bus_reader_pub by
main.cpp
00001 #include "mbed.h" 00002 #include "ecu_reader.h" 00003 #include "globals.h" 00004 00005 ecu_reader obdii(CANSPEED_1M); //Create object and set CAN speed 00006 00007 //Timer CANTimer; 00008 Timer CANTimer2; 00009 00010 int main() { 00011 while(1) 00012 { // Main CAN loop 00013 led2 = 1; 00014 wait(0.1); 00015 led2 = 0; 00016 wait(0.1); 00017 00018 CANTimer2.reset(); 00019 CANTimer2.start(); 00020 pc.printf("CANTimer.start\n"); 00021 00022 while (CANTimer2.read_ms() < TIMEOUT) { 00023 pc.printf("CANTimer.read_ms(): %dms ", CANTimer2.read_ms()); 00024 00025 // http://mbed.org/cookbook/OBDII-Can-Bus 00026 00027 if (can2.read(can_MsgRx)) { 00028 pc.printf("Message read\n\r"); 00029 00030 //print message id 00031 pc.printf("can_MsgRx.id: %x\n\r", can_MsgRx.id); 00032 00033 //print length of message 00034 pc.printf("Hex: can_MsgRx.len: %x\n\r", can_MsgRx.len); 00035 00036 //print data 00037 //pc.printf("can_MsgRx.data[2]: %x\n\r", can_MsgRx.data[5]); 00038 00039 for (int i = 0; i < (int)can_MsgRx.len; i++) { 00040 pc.printf("can_MsgRx.data[%d]: %x\n\r", i, can_MsgRx.data[i]); 00041 } 00042 } 00043 } 00044 } 00045 00046 }
Generated on Mon Aug 1 2022 03:16:42 by
1.7.2
