Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 36

Thread: code wizards, help with some coding? (OBDII diagnostic codes)

  1. #11
    Newbie
    Join Date
    Oct 2008
    Posts
    30
    Quote Originally Posted by Vitaliy View Post
    That's correct. In hex, "P0123" would be 0x0123. The cool thing is that you can easily just read the codes out of the raw OBD stream, I do it sometimes to impress the uninitiated.



    You are absolutely correct, so which part is confusing?



    This is a response to 01 01, which as you correctly said above, means that the MIL is off and there are no stored DTCs.

    Here's a log generated from the ECU Sim (hint: there are two CAN ECUs responding, 10 and 18):

    Code:
    >0101
    18 DA F1 18 06 41 01 81 00 00 00
    18 DA F1 10 06 41 01 86 07 EF 80
    18 DA F1 18 06 41 01 81 00 00 00
    
    >03
    18 DA F1 10 10 0E 43 06 01 00 02 00
    18 DA F1 10 21 03 00 43 00 82 00 C1
    18 DA F1 10 22 00 00 00 00 00 00 00
    18 DA F1 18 04 43 01 01 01
    
    >
    Can you make sense of it?

    Vitaliy

    OK, I'll take a stab at it:

    ECU 10 has 6 stored DTC's
    P0E43
    P0601
    P0002
    P0003
    P0043
    P0082

    ECU 18 has 1 stored DTC
    P0403

    Am I close?

  2. #12
    VENDOR - ScanTool Vitaliy's Avatar
    Join Date
    Dec 2006
    Posts
    587
    Quote Originally Posted by Rooster View Post
    OK, I'll take a stab at it:

    ECU 10 has 6 stored DTC's
    P0E43
    P0601
    P0002
    P0003
    P0043
    P0082

    ECU 18 has 1 stored DTC
    P0403

    Am I close?
    Almost! You did very well but sorry -- it was a trick question!

    18 DA F1 10 10 0E 43 06 01 00 02 00
    18 DA F1 10 21 03 00 43 00 82 00 C1
    18 DA F1 10 22 00 00 00 00 00 00 00

    So the parts in blue are the headers, followed by the sequence numbers. So far so good. What tripped you up was the fact that you also have a byte count ($0E = 15), followed by reply to mode 3 ($43), followed by the number of DTCs (06).

    Wanna give it another try?

    Vitaliy
    You cannot send me a private message using this forum. Use my email instead: vitaliy[@]scantool.net.
    — Did you know that MP3Car sells OBD-2 interfaces? Get your OBDLink for only $84.99!
    — Need to look up a diagnostic trouble code? Try the most up-to-date, free DTCsearch.com!

  3. #13
    Newbie
    Join Date
    Oct 2008
    Posts
    30
    OK, yeah the $0E threw me off.

    How about:
    P0100
    P0200
    P0300
    C0300
    B0200
    U0100

  4. #14
    Newbie
    Join Date
    Oct 2008
    Posts
    30
    Quote Originally Posted by CTdubbin View Post

    if it's really that easy, i don't know why someone hasn't just whipped it up real quick. my only guess is those same people who could whip it up real quick already have their hand in the cookie jar (so to speak). and i'm not going to knock their hustle....
    For what it's worth, here is some of my code.
    It assumes the response from the ELM to a $03 request is contained in the buffer 'ELMrxstr' in the fomat '43 01 33 00 00 00 00' and the number of codes is in 'num_codes'.
    At this point it only handles up to 3 stored DTC's and it does not handle the CAN format (yet).

    I don't know about others, but I am always a little reluctant to post my code because I am just a hacker, so don't be too hard on me !

    (I'm not sure how to use the code window, I hope it is readable. And I don't think the quote at the start from CTdubbin worked quite right?? )

    Code:
    	if(num_codes > 0)
    	{		
    		sendMODEcmd(0x03);				/* request the trouble codes, wait for response */
    			
    			/* --------------- first trouble code ------------------ */
    		MAX_goto_row_col(4,2);				/* set cursor */
    		show_code_hdr(ELMrxstr[3]);			/* 1st char of 1st code */
    		printf("%c", ELMrxstr[4]);			/* print next char */
    		printf("%c", ELMrxstr[6]);			/* ... and next char */
    		printf("%c", ELMrxstr[7]);			/* ... and last char */
    
    			/* --------------- second trouble code ------------------ */
    		if(ELMrxstr[10] == 0x30 & ELMrxstr[12] == 0x30 & ELMrxstr[13] == 0x30);		/* 000 = no code */
    		else
    		{
    			MAX_goto_row_col(5,2);				/* set cursor */
    			show_code_hdr(ELMrxstr[9]);			/* 1st char of 2nd code */
    			printf("%c", ELMrxstr[10]);			/* print next char */
    			printf("%c", ELMrxstr[12]);			/* ... and next char */
    			printf("%c", ELMrxstr[13]);			/* ... and last char */
    		}
    
    			/* --------------- third trouble code ------------------ */
    		if(ELMrxstr[16] == 0x30 & ELMrxstr[18] == 0x30 & ELMrxstr[19] == 0x30);		/* 000 = no code */
    		else
    		{
    			MAX_goto_row_col(6,2);				/* set cursor */
    			show_code_hdr(ELMrxstr[15]);		/* 1st char of 2nd code */
    			printf("%c", ELMrxstr[16]);			/* print next char */
    			printf("%c", ELMrxstr[18]);			/* ... and next char */
    			printf("%c", ELMrxstr[19]);			/* ... and last char */
    		}
    	}
    
    /* ----------------------------------------------------- */
    // show_code_hdr()
    //
    // Show the first part of a trouble code.
    // Pass the first byte of a trouble code to this function.
    // Set cursor position before calling this function.
    //
    /* ----------------------------------------------------- */
    void show_code_hdr(unsigned char value)
    {
    	switch(value)
    	{
    		case 0x30:				/* '0' Powertrain Code - SAE defined */
    		{
    			printf("P0");
    			break ;	
    		}
    		case 0x31:				/* '1' Powertrain Code - manufacturer defined */
    		{
    			printf("P1");
    			break ;	
    		}
    		case 0x32:				/* '2' Powertrain Code - SAE defined */
    		{
    			printf("P2");
    			break ;	
    		}
    		case 0x33:				/* '3' Powertrain Code - jointly defined */
    		{
    			printf("P3");
    			break ;	
    		}
    		case 0x34:				/* '4' Chassis Code - SAE defined  */
    		{
    			printf("C0");
    			break ;	
    		}
    		case 0x35:				/* '5' Chassis Code - manufacturer defined */
    		{
    			printf("C1");
    			break ;	
    		}
    		case 0x36:				/* '6' Chassis Code - manufacturer defined */
    		{
    			printf("C2");
    			break ;	
    		}
    		case 0x37:				/* '7' Chassis Code - reserved for future */
    		{
    			printf("C3");
    			break ;	
    		}
    		case 0x38:				/* '8' Body Code - SAE defined */
    		{
    			printf("B0");
    			break ;	
    		}
    		case 0x39:				/* '9' Body Code - manufacturer defined */
    		{
    			printf("B1");
    			break ;	
    		}
    		case 0x41:				/* 'A' Body Code - manufacturer defined */
    		{
    			printf("B2");
    			break ;	
    		}
    		case 0x42:				/* 'B' Body Code - reserved for future */
    		{
    			printf("B3");
    			break ;	
    		}
    		case 0x43:				/* 'C' Network Code - SAE defined */
    		{
    			printf("U0");
    			break ;	
    		}
    		case 0x44:				/* 'D' Network Code - manufacturer defined */
    		{
    			printf("U1");
    			break ;	
    		}
    		case 0x45:				/* 'E' Network Code - manufacturer defined */
    		{
    			printf("U2");
    			break ;	
    		}
    		case 0x46:				/* 'F' Network Code - reserved for future */
    		{
    			printf("U3");
    			break ;	
    		}
    		default:				/* unrecognized */
    		{
    			printf("xx");
    			break ;	
    		}
    	}
    }

  5. #15
    VENDOR - ScanTool Vitaliy's Avatar
    Join Date
    Dec 2006
    Posts
    587
    Quote Originally Posted by Rooster View Post
    OK, yeah the $0E threw me off.

    How about:
    P0100
    P0200
    P0300
    C0300
    B0200
    U0100
    You got it.
    You cannot send me a private message using this forum. Use my email instead: vitaliy[@]scantool.net.
    — Did you know that MP3Car sells OBD-2 interfaces? Get your OBDLink for only $84.99!
    — Need to look up a diagnostic trouble code? Try the most up-to-date, free DTCsearch.com!

  6. #16
    Newbie
    Join Date
    Oct 2008
    Posts
    30
    Do I win a free ELMScan?

  7. #17
    What can I say? I like serial. Curiosity's Avatar
    Join Date
    Mar 2004
    Location
    Florence Yall, BFKY
    Posts
    2,684
    @Rooster, can I be just a little hard on you?
    Try something more like post #5. You should also convert the hex text into data first, using atoh() or something similar. It will be a lot easier on you in the long run.
    The problem with a switch/case like that is bits A5 and A4 are now reserved for a 5th digit with 2008+ models.
    So in C/C++...
    char cECU[4] = {'P', 'C', 'B', 'U'};

    printf("DTC %c%X%02X", cECU[bytes[0] >> 6], bytes[0] & 0x3F, bytes[1] );

    Note the 0x3F. The first byte can be anywhere from P0 to U39 in BCD.

  8. #18
    Newbie
    Join Date
    Oct 2008
    Posts
    30
    Thanks for the tips.

  9. #19
    Low Bitrate
    Join Date
    Sep 2008
    Posts
    99
    Quote Originally Posted by Vitaliy View Post
    Almost! You did very well but sorry -- it was a trick question!

    18 DA F1 10 10 0E 43 06 01 00 02 00
    18 DA F1 10 21 03 00 43 00 82 00 C1
    18 DA F1 10 22 00 00 00 00 00 00 00

    So the parts in blue are the headers, followed by the sequence numbers. So far so good. What tripped you up was the fact that you also have a byte count ($0E = 15), followed by reply to mode 3 ($43), followed by the number of DTCs (06).

    Wanna give it another try?

    Vitaliy

    I could translate that...or I could just pull up the data sheet on one of your simulators.

  10. #20
    VENDOR - ScanTool Vitaliy's Avatar
    Join Date
    Dec 2006
    Posts
    587
    Quote Originally Posted by Rooster View Post
    Do I win a free ELMScan?
    Nah, ElmScan is so 2008.. How about I send you OBDLink instead?

    Vitaliy
    You cannot send me a private message using this forum. Use my email instead: vitaliy[@]scantool.net.
    — Did you know that MP3Car sells OBD-2 interfaces? Get your OBDLink for only $84.99!
    — Need to look up a diagnostic trouble code? Try the most up-to-date, free DTCsearch.com!

Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 06-11-2006, 06:49 PM
  2. How do I use the Base plugin sources ?
    By guino in forum RR FAQ
    Replies: 1
    Last Post: 04-24-2006, 04:43 PM
  3. wireless OBDII CAN code reader
    By autosvs in forum Engine Management, OBD-II, Engine Diagnostics, etc.
    Replies: 67
    Last Post: 02-09-2006, 09:10 AM
  4. Read OBDII Source Code?
    By Zharvek in forum Engine Management, OBD-II, Engine Diagnostics, etc.
    Replies: 6
    Last Post: 05-19-2005, 08:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •