
//
var blocknum=1;
var flag_sendend = false;
var flag_sending = false;
var alldata = {};
FuncStartSendBlock = function(data){
	blocknum = 0x01;
	flag_sendend = false;
	flag_sending = true;
	alldata = data;
}
FuncStopSendBlock = function(data){
	blocknum = 0x01;
	flag_sendend = false;
	flag_sending = false;
}
FuncGetSendStatus = function(){
	return flag_sendend; 
}
FuncSendNextBlock = function(){
	var len = FuncGetSengLen();
	if(#alldata>len){
		FuncReq36(blocknum,table.slice(alldata,1,len));
		alldata = table.slice(alldata,len+1,)
	}
	else {
		FuncReq36(blocknum,alldata);
		alldata = {};
		flag_sendend = true;
	}
	blocknum += 1;
}


//发送	
FuncReq36 = function(num,data){
	len = #data+2;
	if(len > 7){
		var txdata = {0x10+(len>>8),len&0xff,0x36,num&0xff,data[1],data[2],data[3],data[4]};
		CANHw.SendMsg(DiagReqID,txdata);
		FuncPushPackage(DiagReqID,table.slice(data,5));
	}
	else {
		var txdata = {len,0x36,num&0xff,0, 0,0,0,0};
		for(i=1;#data;1){
			txdata[i+3] = data[i];
		}
		
		CANHw.SendMsg(DiagReqID,txdata);
	}
	
}
//接收
FuncDiag36Pro = function(data){
	//console.dumpJson(data);
	/*
	if(data[1] == blocknum){
		blocknum += 1;
		if(flag_sending == true){
			FuncSendNextBlock();
		}
	}
	*/
}