
var diag22state = 0; 
//发送	
FuncDIDWriteStr = function(did,str){
	var data = {}
	for(i=1;string.len(str);1){
		data[i] = string.unpack(str,i);
	}
	FuncReq2E(did,data)
	return data;
}

//FuncDIDWriteStr(0xf198,"0123456789abcdef1234");

FuncReq2E = function(did,data){
	if(CANHw.isConnected() == false){
		return; 
	}
	if(#data > 4){
		//多帧
		var txdata = {0x10,3+#data,0x2E,did>>8,did&0xff,data[1],data[2],data[3]};
		CANHw.SendMsg(DiagReqID,txdata);
		//等待发送
		FuncPushPackage(DiagReqID,table.slice(data,3));
	}
	else {
		var txdata = {3+#data,0x2E,did>>8,did&0xff,0,0,0,0};
		for(i=1;#data;1){
			txdata[4+i] = data[i];
		}
		CANHw.SendMsg(DiagReqID,txdata);
		
	}
	
}


//接收
FuncDiag2EPro = function(data){
	var did = (data[1]<<8) + data[2];
	FuncDisplay("写入" + tostring(did,16) + "成功");
	
}