diag_l3_iso14230.c

来自「Freediag contains various drivers (ISO91」· C语言 代码 · 共 140 行

C
140
字号
/*
 *	freediag - Vehicle Diagnostic Utility
 *
 *
 * Copyright (C) 2001 Richard Almeida & Ibex Ltd (rpa@ibex.co.uk)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *************************************************************************
 *
 * L7, ISO14230-3 KeyWord 2000 protocol
 * routines
 */

#include <stdlib.h>
#include <stdio.h>

#include "diag_os.h" /* operating specific includes */

#include <fcntl.h>
#include <string.h>
#include <errno.h>

#include "diag.h"
#include "diag_l1.h"
#include "diag_l2.h"
#include "diag_err.h"
#include "diag_general.h"
#include "diag_iso14230.h"

static char *cvsid = "$Id: diag_l3_iso14230.c,v 1.3 2002/04/03 04:56:40 bjorn_helgaas Exp $";

/*
 * We'll use a big switch statement here, and rely on the compiler
 * to make it efficient
 */
char *
diag_l3_iso14230_decode_response(diag_msg_t *msg)
{
	static char buf[1024];
	static char buf2[1024];

	switch (*msg->data)
	{
	default:
		sprintf(buf,"Unknown_response_code 0x%x\n", msg->data[0]);
		break;
	case DIAG_KW2K_RC_SCRPR:
		sprintf(buf,"StartCommunications_OK");
		break;
	case DIAG_KW2K_RC_SPRPR:
		sprintf(buf,"StopCommunications_OK");
		break;
	case DIAG_KW2K_RC_ATPPR:
		sprintf(buf,"AccessTimingParameters_OK");
		break;

	case DIAG_KW2K_RC_NR:
		if (msg->len < 3)
		{
			sprintf(buf, "General_Error no response code\n");
		} else {
			sprintf(buf, "General_Error, Request_ID_0x%x ", msg->data[1]);
			switch (msg->data[2])
			{
			default:
				sprintf(buf2, "Error_0x%x", msg->data[2]);
				break;
			case DIAG_KW2K_RC_GR:
				sprintf(buf2, "General_Reject");
			case DIAG_KW2K_RC_SNS:
				sprintf(buf2, "Service_Not_Supported");
			case DIAG_KW2K_RC_SFNS_IF:
				sprintf(buf2, "SubFunction_Not_Supported");
				break;
			case DIAG_KW2K_RC_B_RR:
				sprintf(buf2, "Busy_Repeat_Request");
				break;
			case DIAG_KW2K_RC_CNCORSE:
				sprintf(buf2, "Conditions_Not_Correct");
				break;
			case DIAG_KW2K_RC_RNC:
				sprintf(buf2, "Routine_Not_Complete");
				break;
			}

			strcat(buf, buf2);
		}
		break;
	}
	return(buf);
}

#if notdef

#define DIAG_KW2K_RC_ROOT	0x31	/* requestOutOfRange */
#define DIAG_KW2K_RC_SAD_SAR	0x33	/* securityAccessDenied-securityAccessRequested */
#define DIAG_KW2K_RC_IK	0x35	/* invalidKey */
#define DIAG_KW2K_RC_ENOA	0x36	/* exceedNumberOfAttempts */
#define DIAG_KW2K_RC_RTDNE	0x37	/* requiredTimeDelayNotExpired */
#define DIAG_KW2K_RC_DNA	0x40	/* downloadNotAccepted */
#define DIAG_KW2K_RC_IDT	0x41	/* improperDownloadType */

#define DIAG_KW2K_RC_CNDTSA	0x42	/* canNotDownloadToSpecifiedAddress */
#define DIAG_KW2K_RC_CNDNOBR	0x43	/* canNotDownloadNumberOfBytesRequested */
#define DIAG_KW2K_RC_UNA	0x50	/* uploadNotAccepted */
#define DIAG_KW2K_RC_IUT	0x51	/* improperUploadType */
#define DIAG_KW2K_RC_CNUFSA	0x52	/* canNotUploadFromSpecifiedAddress */
#define DIAG_KW2K_RC_CNUNOBR	0x53	/* canNotUploadNumberOfBytesRequested */
#define DIAG_KW2K_RC_TS	0x71	/* transferSuspended */
#define DIAG_KW2K_RC_TA	0x72	/* transferAborted */
#define DIAG_KW2K_RC_IAIBT	0x74	/* illegalAddressInBlockTransfer */
#define DIAG_KW2K_RC_IBCIBT	0x75	/* illegalByteCountInBlockTransfer */
#define DIAG_KW2K_RC_IBTT	0x76	/* illegalBlockTransferType */
#define DIAG_KW2K_RC_BTCDE	0x77	/* blockTransferDataChecksumError */
#define DIAG_KW2K_RC_RCR_RP	0x78	/* requestCorrectRcvd-RspPending */
#define DIAG_KW2K_RC_IBCDBT	0x79	/* incorrectByteCountDuringBlockTransfer */
#define DIAG_KW2K_RC_SNSIADS	0x80	/* serviceNotSupportedInActiveDiagnosticMode */


/* 81-8F	reserved */
/* 90-F9	vehicle manufacturer specific */
/* FA-FE	system supplier specific */
/* FF		reserved by document */

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?