var diag22state = 0; 
//发送	
FuncReadDID = function(did){
	if(CANHw.isConnected() == false){
		return; 
	}
	var data = {0x03,0x22,did>>8,did&0xff,0,0,0,0};
	var ret = CANHw.SendMsg(DiagReqID,data);
	diag22state = 1;
	//console.log("did = " + tostring(did,16));
	//console.log("ret = " + ret);
	//FuncDisplay("did = " + tostring(did,16));
}

//接收
FuncDiag22Pro = function(data){
	//console.log("诊断22服务")
	if(#data < 3){
		return;
	}
	var did = (data[1]<<8) + data[2];
	select(did) {
		case 0xF180 {
			FuncDisplay("BOOT版本号");
			FuncDisplay(string.str(string.pack(table.slice(data,3))));

		}
		case 0xF186 {
			FuncDisplay("当前会话： " + data[3]);
		}
		case 0xF193 {
			FuncDisplay("硬件版本号");
			FuncDisplay(string.str(string.pack(table.slice(data,3))));
		}
		case 0xF195 {
			FuncDisplay("软件版本号");
			FuncDisplay(string.str(string.pack(table.slice(data,3))));
		}
		case 0xF191 {
			FuncDisplay("编译时间");
			FuncDisplay(string.str(string.pack(table.slice(data,3))));
		}
		case 0xF187 {
			FuncDisplay("ECU系统名称");
			FuncDisplay(string.str(string.pack(table.slice(data,3))));

		}
		case 0xF198 {
			FuncDisplay("repair_shopcode");
			FuncDisplay(string.str(string.pack(table.slice(data,3))));
		}
		case 0xF199 {
			FuncDisplay("installation_date");
			FuncDisplay(string.format("%x%X%x%x",data[3],data[4],data[5],data[6]));
		}
		
		case 0xF18A {
			FuncDisplay("系统供应商公司名称代码");
			FuncDisplay(string.pack(table.slice(data,3)));

		}
		case 0xF197 {
			FuncDisplay("ECU  系统名称");
			FuncDisplay(string.pack(table.slice(data,3)));

		}
		else {
			FuncDisplay("未知DID - " + tostring(did,16));
		}
	}
	
}