SetRegisterRAMBUF

You are here:
Estimated reading time: 1 min
Go back to the VM operations list

Prototype

SetRegisterRAMBUF (r, regOffset)

Description

Put content of r in register at regOffset (RAMBUF)

Return
Nothing

Code Example

The following code example uses the SetRegisterRAMBUF function.

The SMK900.evi file used for this example can be downloaded at the bottom of this page.
/* Example Code
* SetRegisterRAMBUF
*
* get buffer index r and regOffset and regLen
* set buffer in memory
* set RAMBUF[regOffset] to buffer[r]
* get RAMBUF[regOffset]
* if params used 
* 	return result of get on regLen*8 bits
* else 
* 	return 0x00 (set/get not ok) or 0x01 (set/get ok) on 8 bits
*
* example VMExecuteCmd:
* cmd: 															   |r        |regOffset|regLen|buffer
*		0xfb 0x0e 0x00 0x0c 0x00 0x0e [0x?? 0x?? 0x?? = macAdress] 0x00 0x00 0x03 0x00 0x01 0x01
* rsp: 	0xfb 0x08 0x00 0x2d 0x00 0xe1 0x1e 0x01
*/


#include "SMK900.evi"

#define SENSORCODE 0x01
	
function exec_aircmd(){
	local rxLen;
	local useParams;
	local r, regOffset, regLen;
	local i;
	local result;
	
	rxLen=GetAirBuf(0, 0, 20);
	
	if(rxLen>=7){ // 1 byte for paketID + 6 bytes of payload (5 bytes for param + minimum 1 byte of buffer)
		useParams=true;
		r=GetBuffer_16(1);
		regOffset=GetBuffer_16(3);
		regLen=GetBuffer_S8(5);
		for(i=6;i<rxLen;i++){
			SetBuffer(i-6,GetBuffer_S8(i),1);
		}
	}else{	
		useParams=false;
		r=0;
		regOffset=REGISTER_NWKID;
		regLen=1;
		SetBuffer(0,0x01,1);
		//SetBuffer(1,0x00,1);
	}
	
	/*GetRegisterRAMBUF(0,3); // recupere le nwkID
	SetBuffer(1,0x02,1); // init nouvelle val du nwkID
	SetRegisterRAMBUF(1,3); // ecrit nouvelle val de nwkID dans RAMBUF
	GetRegisterRAMBUF(2,3); // recupere le nwkID
	
	Send(3);*/
	
	SetRegisterRAMBUF(r,regOffset);
	GetRegisterRAMBUF(0,regOffset);
	
	if(useParams){
		Send(regLen);
	}else{
		if(GetBuffer_S8(0)==0x01){
			result = 1;
		}else{
			result = 0;
		}
		SetBuffer(0,result,1);
		Send(1);
	}

		
}

function main() 
{
	local execType;
	
	execType = GetExecType();
	if(execType==MESHEXECTYPE_AIRCMD_bm){
		exec_aircmd();
	}
}

Go back to the VM operations list

Attachments

Was this article helpful?
Dislike 0
Views: 64
Go to Top