
METERING AND M BUS
2.5
Metering Application Script {MBUS.sc}
/*globals*/
int MAXCFGWORD = 0x2CC4; /* Check this */
int MAXDATA = 30;
int CALL_STATUS = 12;/*byte is status register*/
int RINGING = 1;/*CALL STATUS value*/
char DATA_NUMBER[12] = “07867900940”; /*change this to your number*/
int CALL_COUNT = 1000; /* wait for Data Connection Count */
int GETLOOPCNT = 100; /* check data call status every 100 loops */
int REC10MSCNT = 10; /* 100ms receive wait */
char Recp[261];
char iRec[261];
int st;
/*operates on Recp and iRec*/
GetMBUSData (int RcNotRsp)
{
/*Get MBUS data from Channel or Device*/
/*Contains
MBUS
packet validation algorithm*/
int Size = 0;
int index = 0;
int di = 0;
int len = 0;
int cnt = 0;
while(st != 0) /*Possibly check on data call status as well?*/
{
if(di >= Size)
{
Size = 0;
if(RcNotRsp
>
0)
{
Size = chr(1,iRec,255); /*read more data from
channel*/
}
else
{
Size
=
mxr(iRec,261);
}
di = 0;
}
/*validate the MBUS packet*/
if(Size > 0)
{
Recp[index++]
=
iRec[di++];
if(Recp[0]
==
0xE5)
{
len = 1;
break;
}
else if(Recp[0] == 0x10)
{
if(index
>=
5)
{
index = 0;
if(Recp[4]
==
0x16)
{
len = 5;
break;
}
}
LZT 123 8014 R1A
8