
FuncReq31EraseFlash = function(addr,len){
	FuncDisplay("开始擦除数据")
	var data = {0xff,0x00,0x44,addr>>24,addr>>16,addr>>8,addr,len>>24,len>>16,len>>8,len};
	FuncReq31(data);
}

FuncReq31CheckLogicBlock = function(crc){//(addr,len)
	//var data = {0x02,0x02,0x44,addr>>24,addr>>16,addr>>8,addr,len>>24,len>>16,len>>8,len};
	var data = {0x02,0x02,crc>>24,crc>>16,crc>>8,crc};
	FuncReq31(data);
}
FuncReq31CheckPD = function(){//Programming Dependencies
	var data = {0xFF,0x01};
	FuncReq31(data);
}
FuncReq31CheckFlash = function(){
	var data = {0x02,0x02};
	FuncReq31(data);
}




//发送	
FuncReq31 = function(data){
	if(#data > 5){//多帧
		var txdata = {0x10,2+#data,0x31,0x01,data[1],data[2],data[3],data[4]};
		CANHw.SendMsg(DiagReqID,txdata);
		FuncPushPackage(DiagReqID,table.slice(data,5));
	}
	else {
		var txdata = {2+#data,0x31,0x01,0, 0,0,0,0};
		for(i=1;#data;1){
			txdata[3+i] = data[i];
		}
		CANHw.SendMsg(DiagReqID,txdata);
	}
	
	
}
//接收
FuncDiag31Pro = function(data){
	//console.dumpJson(data);
	var rid = (data[2]<<8) + data[3];
	select(rid) {
		case 0xFF00 {
			FuncDisplay("擦除成功")
		}
		case 0x0202 {
			FuncDisplay("校验成功")
		}
		case 0xFF01 {
			FuncDisplay("检查标志成功")
		}
		case 0xF518 {
			FuncDisplay("数字签名错误")
		}
		else {
		}
	}
}