Open OBC / Mbed 2 deprecated obdtest

Dependencies:   mbed e36obd

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 #include "E36obd.h"
00004 
00005 Serial dbg(USBTX, USBRX);
00006 
00007 int main()
00008 {
00009     //dbg.baud(115200);
00010     
00011     //the DS2 class will need two bus objects for TXD (K bus) and RXD (L bus)
00012     //the Bus class derives from the mbed Serial class and each needs a tx/rx pair of serial pins
00013     //4 pins total are used in this implementation (2 serial port peripherals)
00014     Bus* k_line = new Bus(p9, p10);
00015     Bus* l_line = new Bus(p13, p14);
00016     DS2 ds2(k_line, l_line);
00017     
00018     //we can run some basic tests on the interface
00019     //if they fail, check the source to see how
00020     if(!k_line->test())
00021         printf("k_line test failed - check interface hardware\r\n");
00022     if(!l_line->test())
00023         printf("l_line test failed - check interface hardware\r\n");
00024     if(!ds2.test())
00025         printf("ds2 test failed\r\n");
00026     //nothing below will work if these failed
00027     
00028     //DS2::testModule will attempt to raise a module by address
00029     //in much the same way that INPA does
00030     int address = 0x00; //zke4
00031     ds2.testModule(address);
00032     
00033     //more modules - some have multiple addresses to try
00034     ds2.testModule(0x80); //kombi
00035     ds2.testModule(0x0d); //kombi
00036     ds2.testModule(0x59); //ihkr
00037     ds2.testModule(0x5b); //ihka
00038     ds2.testModule(0x36); //mk4
00039     ds2.testModule(0x56); //mk20
00040     ds2.testModule(0xcd); //obc
00041     ds2.testModule(0xa4); //srs
00042     ds2.testModule(0x44); //ews
00043     ds2.testModule(0x60); //pdc
00044     ds2.testModule(0x12); //dme4
00045     
00046     printf("done querying modules\r\n");
00047     
00048     //here we can snoop inpa traffic and print it to dbg
00049     //this will never return
00050     ds2.snoop();
00051     
00052 
00053 }